service client and a simple DB example

This commit is contained in:
云风
2012-08-06 19:58:35 +08:00
parent b33d438715
commit 56f30e7f7f
12 changed files with 157 additions and 21 deletions

View File

@@ -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