12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- --[[
- Author: zkj
- Date: 2021-05-31 14:14:53
- LastEditTime: 2021-06-01 11:00:59
- LastEditors: Please set LastEditors
- Description: battle agent 管理服务
- --]]
- local const = require "const.const"
- local skynet = require "skynet"
- local agentPool = require "agentPool"
- local baseService = require("baseService")
- local pool
- local CMD = {}
- function CMD.getBattleAgent()
- return pool:alloc_agent_srv()
- end
- -- from agent
- function CMD.battleEnter(id, battleAgent)
- pool:bind_agent(id, battleAgent)
- end
- -- from agent
- function CMD.battleLeave(id, battleAgent)
- pool:unbind_agent(id, battleAgent)
- end
- -- 玩家是否在战斗中
- function CMD.is_user_in_battle(uid, battleId, battleAgent)
- if battleAgent == nil or not pool:get_agent_info_by_addr(battleAgent) then
- return false
- end
- local ok = skynet.call(battleAgent, "lua", "is_user_in_battle", uid, battleId)
- return ok
- end
- function CMD.onStart()
- pool = agentPool.new("srvBattle", const.INIT_AGENT_COUNT)
- end
- baseService.start(CMD, ".BattleMgr", true)
|