rewrite example testping

This commit is contained in:
Cloud Wu
2014-04-04 11:50:10 +08:00
parent 1a07e94ad5
commit 3be4e3c44b
2 changed files with 6 additions and 5 deletions

View File

@@ -3,12 +3,12 @@ local skynet = require "skynet"
local command = {}
function command.PING(hello)
skynet.ret(skynet.pack(hello))
return hello
end
function command.HELLO()
skynet.sleep(100)
skynet.ret(skynet.pack("hello"))
return "hello"
end
function command.EXIT()
@@ -19,8 +19,9 @@ function command.ERROR()
error "throw an error"
end
skynet.start(function()
skynet.dispatch("lua", function(session,addr, cmd, ...)
command[cmd](...)
skynet.ret(skynet.pack(command[cmd](...)))
end)
end)