123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- 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("<Gift>,")
- skynet.dispatch("lua", function(session,_, cmd, ...)
- local f = assert(CMD[cmd])
- if session == 0 then
- f(...)
- else
- skynet_retpack(f(...))
- end
- end)
- end)
|