mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
gate: application could control when to start receiving data
This commit is contained in:
@@ -132,7 +132,12 @@ _ctrl(struct gate * g, const void * msg, int sz) {
|
||||
return;
|
||||
}
|
||||
if (memcmp(command,"start",i) == 0) {
|
||||
skynet_socket_start(ctx, g->listen_id);
|
||||
_parm(tmp, sz, i);
|
||||
int uid = strtol(command , NULL, 10);
|
||||
int id = hashid_lookup(&g->hash, uid);
|
||||
if (id>=0) {
|
||||
skynet_socket_start(ctx, uid);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (memcmp(command, "close", i) == 0) {
|
||||
@@ -225,10 +230,7 @@ dispatch_socket_message(struct gate *g, const struct skynet_socket_message * mes
|
||||
break;
|
||||
}
|
||||
int id = hashid_lookup(&g->hash, message->id);
|
||||
if (id>=0) {
|
||||
struct connection *c = &g->conn[id];
|
||||
_report(g, "%d open %d %s:0",message->id,message->id,c->remote_name);
|
||||
} else {
|
||||
if (id<0) {
|
||||
skynet_error(ctx, "Close unknown connection %d", message->id);
|
||||
skynet_socket_close(ctx, message->id);
|
||||
}
|
||||
@@ -259,7 +261,8 @@ dispatch_socket_message(struct gate *g, const struct skynet_socket_message * mes
|
||||
c->id = message->ud;
|
||||
memcpy(c->remote_name, message+1, sz);
|
||||
c->remote_name[sz] = '\0';
|
||||
skynet_socket_start(ctx, message->ud);
|
||||
_report(g, "%d open %d %s:0",c->id, c->id, c->remote_name);
|
||||
skynet_error(ctx, "socket open: %x", c->id);
|
||||
}
|
||||
break;
|
||||
case SKYNET_SOCKET_TYPE_WARNING:
|
||||
@@ -327,6 +330,7 @@ start_listen(struct gate *g, char * listen_addr) {
|
||||
if (g->listen_id < 0) {
|
||||
return 1;
|
||||
}
|
||||
skynet_socket_start(ctx, g->listen_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user