mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
service client and a simple DB example
This commit is contained in:
14
gate/main.c
14
gate/main.c
@@ -118,10 +118,16 @@ _report(struct skynet_context * ctx, const char * data, ...) {
|
||||
static void
|
||||
_forward(struct skynet_context * ctx,struct gate *g, int uid, void * data, size_t len) {
|
||||
struct connection * agent = _id_to_agent(g,uid);
|
||||
char * tmp = malloc(len + 32);
|
||||
int n = snprintf(tmp,len+32,"%d data ",uid);
|
||||
memcpy(tmp+n,data,len);
|
||||
skynet_send(ctx, agent->agent ? agent->agent : WATCHDOG, 0, tmp, len + n);
|
||||
if (agent->agent) {
|
||||
char * tmp = malloc(len);
|
||||
memcpy(tmp,data,len);
|
||||
skynet_send(ctx, agent->agent, 0, tmp, len);
|
||||
} else {
|
||||
char * tmp = malloc(len + 32);
|
||||
int n = snprintf(tmp,len+32,"%d data ",uid);
|
||||
memcpy(tmp+n,data,len);
|
||||
skynet_send(ctx, WATCHDOG, 0, tmp, len + n);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
Reference in New Issue
Block a user