Permalink
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (28 sloc) 885 Bytes
local skynet = require "skynet"
local cluster = require "skynet.cluster"
require "skynet.manager" -- inject skynet.forward_type
local node, address = ...
skynet.register_protocol {
name = "system",
id = skynet.PTYPE_SYSTEM,
unpack = function (...) return ... end,
}
local forward_map = {
[skynet.PTYPE_SNAX] = skynet.PTYPE_SYSTEM,
[skynet.PTYPE_LUA] = skynet.PTYPE_SYSTEM,
[skynet.PTYPE_RESPONSE] = skynet.PTYPE_RESPONSE, -- don't free response message
}
skynet.forward_type( forward_map ,function()
local clusterd = skynet.uniqueservice("clusterd")
local n = tonumber(address)
if n then
address = n
end
skynet.dispatch("system", function (session, source, msg, sz)
if session == 0 then
skynet.send(clusterd, "lua", "push", node, address, msg, sz)
else
skynet.ret(skynet.rawcall(clusterd, "lua", skynet.pack("req", node, address, msg, sz)))
end
end)
end)