msggate example

This commit is contained in:
Cloud Wu
2014-07-13 19:36:44 +08:00
parent e1674f04c3
commit 0cdd71c0c2
8 changed files with 448 additions and 25 deletions

View File

@@ -0,0 +1,27 @@
local skynet = require "skynet"
skynet.register_protocol {
name = "client",
id = skynet.PTYPE_CLIENT,
unpack = skynet.tostring,
}
local gate
local CMD = {}
function CMD.init(source , uid, server)
gate = source
skynet.error(string.format("%s is coming", uid))
end
skynet.start(function()
skynet.dispatch("lua", function(_, source, command, ...)
local f = assert(CMD[command])
skynet.ret(skynet.pack(f(source, ...)))
end)
skynet.dispatch("client", function(_,_, msg)
skynet.ret(msg)
end)
end)