global group multicast

This commit is contained in:
云风
2012-08-30 23:31:33 +08:00
parent 161528e686
commit 1ee802c5c5
17 changed files with 285 additions and 40 deletions

30
lualib/mcgroup.lua Normal file
View File

@@ -0,0 +1,30 @@
local skynet = require "skynet"
local SERVICE = "GROUPMGR"
local group = {}
function group.create()
return skynet.call(SERVICE, skynet.unpack, skynet.pack("NEW" , skynet.self()))
end
function group.address(id)
local send_id = id * 2 + 1
return skynet.query_group(send_id)
end
function group.enter(id, handle)
handle = handle or skynet.self()
skynet.send(SERVICE, 0 , skynet.pack("ENTER", handle, id))
end
function group.leave(id, handle)
handle = handle or skynet.self()
skynet.send(SERVICE, 0 , skynet.pack("LEAVE", handle, id))
end
function group.release(id)
skynet.send(SERVICE, 0 , skynet.pack("CLEAR", skynet.self(), id))
end
return group