Blame view

publish/skynet/service/service_cell.lua 489 Bytes
4d6f285d   zhouhaihai   增加发布功能
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  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)