Files
skynet/service/testrobj.lua
2012-08-31 21:18:19 +08:00

24 lines
394 B
Lua

local skynet = require "skynet"
local obj = { id = 0 }
function obj.hello()
return "Hello"
end
function obj:inc()
self.id = self.id + 1
return self.id
end
skynet.start(function()
skynet.remote_create(obj)
local root = skynet.remote_root()
print(root.echo("hello"))
root.register("test",obj)
local qobj = root.query "test"
print(qobj.hello())
print(qobj:inc())
skynet.exit()
end)