remove netpack from gate service

This commit is contained in:
Cloud Wu
2018-09-12 11:45:41 +08:00
parent 823b773051
commit c839159470

View File

@@ -1,6 +1,5 @@
local skynet = require "skynet"
local gateserver = require "snax.gateserver"
local netpack = require "skynet.netpack"
local watchdog
local connection = {} -- fd -> connection : { fd , client, agent , ip, mode }
@@ -22,9 +21,12 @@ function handler.message(fd, msg, sz)
local c = connection[fd]
local agent = c.agent
if agent then
-- It's safe to redirect msg directly , gateserver framework will not free msg.
skynet.redirect(agent, c.client, "client", fd, msg, sz)
else
skynet.send(watchdog, "lua", "socket", "data", fd, netpack.tostring(msg, sz))
skynet.send(watchdog, "lua", "socket", "data", fd, skynet.tostring(msg, sz))
-- skynet.tostring will copy msg to a string, so we must free msg here.
skynet.trash(msg,sz)
end
end