mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
change source dir
This commit is contained in:
27
service/launcher.lua
Normal file
27
service/launcher.lua
Normal file
@@ -0,0 +1,27 @@
|
||||
local skynet = require "skynet"
|
||||
local string = string
|
||||
|
||||
local instance = {}
|
||||
|
||||
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], address)
|
||||
instance[address] = nil
|
||||
end
|
||||
else
|
||||
-- launch request
|
||||
local service, param = string.match(message, "([^ ]+) (.*)")
|
||||
local inst = skynet.launch(service, param)
|
||||
if inst then
|
||||
instance[inst] = { session, address }
|
||||
else
|
||||
skynet.send(address, session)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
skynet.register(".launcher")
|
||||
Reference in New Issue
Block a user