mcgroup bugfix

This commit is contained in:
云风
2012-09-17 11:37:08 +08:00
parent 6ce12d1180
commit f4c395759b
3 changed files with 16 additions and 12 deletions

View File

@@ -24,12 +24,12 @@ function group.leave(id, handle)
end
function group.release(id)
skynet.send(SERVICE, "lua" , "CLEAR", skynet.self(), id)
skynet.send(SERVICE, "lua" , "DELETE", skynet.self(), id)
end
skynet.init(function()
SERVICE = skynet.call("SERVICE", "lua", "group_mgr")
skynet.call(".service","lua","group_agent")
end, "group")
skynet.call(".service","lua","group_agent", SERVICE)
end, "mcgroup")
return group

View File

@@ -1,5 +1,9 @@
local skynet = require "skynet"
local group_mgr = ...
group_mgr = tonumber(group_mgr)
local command = {}
local group = {}
@@ -52,5 +56,5 @@ skynet.start(function()
assert(f, cmd)
f(id,handle)
end)
skynet.send("GROUPMGR" , "lua", "MASTER", skynet.self())
skynet.send(group_mgr , "lua", "MASTER", skynet.self())
end)

View File

@@ -12,9 +12,12 @@ end
local function create_group_in(harbor, id)
local local_ctrl = assert(harbor_ctrl[harbor])
local g = multicast[id]
g[harbor] = false
local local_mc = skynet.call(local_ctrl, "lua", "CREATE", id)
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
for harbor_id,ctrl in pairs(harbor_ctrl) do
if harbor_id ~= harbor then
@@ -42,15 +45,13 @@ function command.ENTER(address, harbor, id)
end
function command.LEAVE(address, harbor, id)
local g = multicast[id]
assert(g,id)
assert(multicast[id], id)
local local_ctrl = assert(harbor_ctrl[harbor])
skynet.send(local_ctrl, "lua", "LEAVE", id, address)
end
function command.DELETE(_,_, id)
local g = multicast[id]
assert(g,id)
assert(multicast[id], id)
multicast[id] = nil
for harbor_id,_ in pairs(g) do
@@ -59,12 +60,11 @@ function command.DELETE(_,_, id)
end
skynet.start(function()
skynet.dispatch("lua", function(_, _, cmd , address, param)
skynet.dispatch("lua", function(_, _, cmd, address, param)
local f = command[cmd]
assert(f, cmd, param)
local harbor = skynet.harbor(address)
f(address, harbor, param)
end)
skynet.register("GROUPMGR")
end)