watchdog returns addr,port

This commit is contained in:
Cloud Wu
2022-09-04 14:22:13 +08:00
parent 01314de8e1
commit b61daaccf1
5 changed files with 33 additions and 6 deletions

View File

@@ -22,6 +22,7 @@
#define TYPE_OPEN 4
#define TYPE_CLOSE 5
#define TYPE_WARNING 6
#define TYPE_INIT 7
/*
Each package is uint16 + data , uint16 (serialized in big-endian) is the number of bytes comprising the data .
@@ -354,8 +355,11 @@ lfilter(lua_State *L) {
assert(size == -1); // never padding string
return filter_data(L, message->id, (uint8_t *)buffer, message->ud);
case SKYNET_SOCKET_TYPE_CONNECT:
// ignore listen fd connect
return 1;
lua_pushvalue(L, lua_upvalueindex(TYPE_INIT));
lua_pushinteger(L, message->id);
lua_pushlstring(L, buffer, size);
lua_pushinteger(L, message->ud);
return 5;
case SKYNET_SOCKET_TYPE_CLOSE:
// no more data in fd (message->id)
close_uncomplete(L, message->id);
@@ -483,8 +487,9 @@ luaopen_skynet_netpack(lua_State *L) {
lua_pushliteral(L, "open");
lua_pushliteral(L, "close");
lua_pushliteral(L, "warning");
lua_pushliteral(L, "init");
lua_pushcclosure(L, lfilter, 6);
lua_pushcclosure(L, lfilter, 7);
lua_setfield(L, -2, "filter");
return 1;