mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
global group multicast
This commit is contained in:
30
lualib/mcgroup.lua
Normal file
30
lualib/mcgroup.lua
Normal 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
|
||||
Reference in New Issue
Block a user