mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
28 lines
768 B
Lua
28 lines
768 B
Lua
local skynet = require "skynet"
|
|
local cluster = require "cluster"
|
|
|
|
local node, address = ...
|
|
|
|
skynet.register_protocol {
|
|
name = "system",
|
|
id = skynet.PTYPE_SYSTEM,
|
|
unpack = function (...) return ... end,
|
|
}
|
|
|
|
local forward_map = {
|
|
[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)
|
|
local m,s = skynet.rawcall(clusterd, "lua", skynet.pack("req", node, address, msg, sz))
|
|
skynet.ret(skynet.rawcall(clusterd, "lua", skynet.pack("req", node, address, msg, sz)))
|
|
end)
|
|
end)
|