static int _mainloop(struct skynet_context * context, void * ud, int type, int session, uint32_t source, const void * msg, size_t sz) { if (type == PTYPE_SOCKET) { dispatch_socket((struct master *)ud, (const skynet_socket_message *)msg, (int)sz); return 0; } if (type != PTYPE_HARBOR) { skynet_error(context, "None harbor message recv from %x (type = %d)", source, type); return 0; } assert(sz >= 4); struct master *m = (struct master*)ud; const uint8_t *handlen = (const uint8_t *)msg; uint32_t handle = handlen[0]<<24 | handlen[1]<<16 | handlen[2]<<8 | handlen[3]; sz -= 4; const char * name = (const char *)msg; name += 4; if (handle == 0) { _request_name(m , name, sz); } else if (handle < REMOTE_MAX) { _update_address(m , handle, name, sz); } else { _update_name(m , handle, name, sz); } return 0; }
static int _mainloop(struct skynet_context * context, void * ud, int type, int session, uint32_t source, const void * msg, size_t sz) { if (type != PTYPE_HARBOR) { skynet_error(context, "None harbor message recv from %x (type = %d)", source, type); return 0; } struct master *m = ud; uint32_t handle = 0; memcpy(&handle, msg, 4); handle = ntohl(handle); sz -= 4; const char * name = msg; name += 4; if (handle == 0) { _request_name(context, m , name, sz); } else if (handle < REMOTE_MAX) { _update_address(context, m , handle, name, sz); } else { _update_name(context, m , handle, name, sz); } return 0; }