mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 04:33:05 +00:00
mcgroup bugfix
This commit is contained in:
@@ -24,12 +24,12 @@ function group.leave(id, handle)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function group.release(id)
|
function group.release(id)
|
||||||
skynet.send(SERVICE, "lua" , "CLEAR", skynet.self(), id)
|
skynet.send(SERVICE, "lua" , "DELETE", skynet.self(), id)
|
||||||
end
|
end
|
||||||
|
|
||||||
skynet.init(function()
|
skynet.init(function()
|
||||||
SERVICE = skynet.call("SERVICE", "lua", "group_mgr")
|
SERVICE = skynet.call("SERVICE", "lua", "group_mgr")
|
||||||
skynet.call(".service","lua","group_agent")
|
skynet.call(".service","lua","group_agent", SERVICE)
|
||||||
end, "group")
|
end, "mcgroup")
|
||||||
|
|
||||||
return group
|
return group
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
local skynet = require "skynet"
|
local skynet = require "skynet"
|
||||||
|
|
||||||
|
local group_mgr = ...
|
||||||
|
|
||||||
|
group_mgr = tonumber(group_mgr)
|
||||||
|
|
||||||
local command = {}
|
local command = {}
|
||||||
local group = {}
|
local group = {}
|
||||||
|
|
||||||
@@ -52,5 +56,5 @@ skynet.start(function()
|
|||||||
assert(f, cmd)
|
assert(f, cmd)
|
||||||
f(id,handle)
|
f(id,handle)
|
||||||
end)
|
end)
|
||||||
skynet.send("GROUPMGR" , "lua", "MASTER", skynet.self())
|
skynet.send(group_mgr , "lua", "MASTER", skynet.self())
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -12,9 +12,12 @@ end
|
|||||||
local function create_group_in(harbor, id)
|
local function create_group_in(harbor, id)
|
||||||
local local_ctrl = assert(harbor_ctrl[harbor])
|
local local_ctrl = assert(harbor_ctrl[harbor])
|
||||||
local g = multicast[id]
|
local g = multicast[id]
|
||||||
|
g[harbor] = false
|
||||||
local local_mc = skynet.call(local_ctrl, "lua", "CREATE", id)
|
local local_mc = skynet.call(local_ctrl, "lua", "CREATE", id)
|
||||||
for _,mc in pairs(g) do
|
for _,mc in pairs(g) do
|
||||||
skynet.send(local_ctrl, "lua", "AGENT", id, mc)
|
if mc then
|
||||||
|
skynet.send(local_ctrl, "lua", "AGENT", id, mc)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
for harbor_id,ctrl in pairs(harbor_ctrl) do
|
for harbor_id,ctrl in pairs(harbor_ctrl) do
|
||||||
if harbor_id ~= harbor then
|
if harbor_id ~= harbor then
|
||||||
@@ -42,15 +45,13 @@ function command.ENTER(address, harbor, id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function command.LEAVE(address, harbor, id)
|
function command.LEAVE(address, harbor, id)
|
||||||
local g = multicast[id]
|
assert(multicast[id], id)
|
||||||
assert(g,id)
|
|
||||||
local local_ctrl = assert(harbor_ctrl[harbor])
|
local local_ctrl = assert(harbor_ctrl[harbor])
|
||||||
skynet.send(local_ctrl, "lua", "LEAVE", id, address)
|
skynet.send(local_ctrl, "lua", "LEAVE", id, address)
|
||||||
end
|
end
|
||||||
|
|
||||||
function command.DELETE(_,_, id)
|
function command.DELETE(_,_, id)
|
||||||
local g = multicast[id]
|
assert(multicast[id], id)
|
||||||
assert(g,id)
|
|
||||||
multicast[id] = nil
|
multicast[id] = nil
|
||||||
|
|
||||||
for harbor_id,_ in pairs(g) do
|
for harbor_id,_ in pairs(g) do
|
||||||
@@ -59,12 +60,11 @@ function command.DELETE(_,_, id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
skynet.start(function()
|
skynet.start(function()
|
||||||
skynet.dispatch("lua", function(_, _, cmd , address, param)
|
skynet.dispatch("lua", function(_, _, cmd, address, param)
|
||||||
local f = command[cmd]
|
local f = command[cmd]
|
||||||
assert(f, cmd, param)
|
assert(f, cmd, param)
|
||||||
local harbor = skynet.harbor(address)
|
local harbor = skynet.harbor(address)
|
||||||
f(address, harbor, param)
|
f(address, harbor, param)
|
||||||
end)
|
end)
|
||||||
skynet.register("GROUPMGR")
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user