mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 11:03:12 +00:00
25 lines
481 B
Lua
25 lines
481 B
Lua
local skynet = require "skynet"
|
|
|
|
skynet.register_protocol {
|
|
name = "text",
|
|
id = skynet.PTYPE_TEXT,
|
|
pack = function (...)
|
|
local n = select ("#" , ...)
|
|
if n == 0 then
|
|
return ""
|
|
elseif n == 1 then
|
|
return tostring(...)
|
|
else
|
|
return table.concat({...}," ")
|
|
end
|
|
end,
|
|
unpack = skynet.tostring
|
|
}
|
|
|
|
skynet.start(function()
|
|
skynet.dispatch("text", function(session, address, text)
|
|
print("[GLOBALLOG]", skynet.address(address),text)
|
|
end)
|
|
skynet.register "LOG"
|
|
end)
|