From 30279f2f8dc238453d337a63b7c7e09a10c04361 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Mon, 18 Jan 2021 16:56:46 +0800 Subject: [PATCH] Add gameserver embed mode, see #1326 --- lualib/snax/gateserver.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lualib/snax/gateserver.lua b/lualib/snax/gateserver.lua index b5165e2b..74a19669 100644 --- a/lualib/snax/gateserver.lua +++ b/lualib/snax/gateserver.lua @@ -141,7 +141,7 @@ function gateserver.start(handler) end } - skynet.start(function() + local function init() skynet.dispatch("lua", function (_, address, cmd, ...) local f = CMD[cmd] if f then @@ -150,7 +150,13 @@ function gateserver.start(handler) skynet.ret(skynet.pack(handler.command(cmd, address, ...))) end end) - end) + end + + if handler.embed then + init() + else + skynet.start(init) + end end return gateserver