remove broker and add group command

This commit is contained in:
云风
2012-08-30 17:26:48 +08:00
parent f4a895fa6f
commit 4610781498
7 changed files with 36 additions and 129 deletions

View File

@@ -3,23 +3,26 @@ local string = string
local instance = {}
local function _extract( service, ...)
return service , table.concat({...}, " ")
end
skynet.dispatch(function(msg, sz , session, address)
local message = skynet.tostring(msg,sz)
if session == 0 then
-- init notice
local reply = instance[address]
if reply then
skynet.send(reply[2] , reply[1], skynet.address(address))
skynet.send(reply[2] , reply[1], skynet.pack(address))
instance[address] = nil
end
else
-- launch request
local service, param = string.match(message, "([^ ]+) (.*)")
local service , param = _extract(skynet.unpack(msg,sz))
local inst = skynet.launch(service, param)
if inst then
instance[inst] = { session, address }
else
skynet.send(address, session)
skynet.send(address, session, skynet.pack(nil))
end
end
end)