mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 11:03:12 +00:00
24 lines
394 B
Lua
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)
|