local skynet = require "skynet" require "skynet.manager" local logger = require "logger" local asset = require "model.asset" local stringify = require "stringify" local skynet_retpack = skynet.retpack local list = { --[[ [shop_type] = { { id = id num = num } } ]] } local CMD = {} local function optimize() local temp = {} for _, conf in pairs(asset.GiftConfig_proto) do temp[conf.type] = temp[conf.type] or {} table.insert(temp[conf.type], conf) end list = temp -- logger.trace("gift:"..stringify(list)) end function CMD.start() logger.info("start") optimize() end function CMD.get_all_gift(model_id) return list[model_id] or {} end skynet.init(function() skynet.register(".gift") end) skynet.start(function() logger.label(",") skynet.dispatch("lua", function(session,_, cmd, ...) local f = assert(CMD[cmd]) if session == 0 then f(...) else skynet_retpack(f(...)) end end) end)