You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
489 B
Lua
25 lines
489 B
Lua
local skynet = require "skynet"
|
|
|
|
local service_name = (...)
|
|
local init = {}
|
|
|
|
function init.init(code, ...)
|
|
local start_func
|
|
skynet.start = function(f)
|
|
start_func = f
|
|
end
|
|
skynet.dispatch("lua", function() error("No dispatch function") end)
|
|
local mainfunc = assert(load(code, service_name))
|
|
assert(skynet.pcall(mainfunc,...))
|
|
if start_func then
|
|
start_func()
|
|
end
|
|
skynet.ret()
|
|
end
|
|
|
|
skynet.start(function()
|
|
skynet.dispatch("lua", function(_,_,cmd,...)
|
|
init[cmd](...)
|
|
end)
|
|
end)
|