srvMatch.lua 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --[[
  2. Descripttion:房间管理
  3. version:
  4. Author: Neo,Huang
  5. Date: 2023-11-16 22:19:05
  6. LastEditors: Neo,Huang
  7. LastEditTime: 2023-11-16 23:19:50
  8. --]]
  9. local timer = require("timer")
  10. local baseService = require("baseService")
  11. local util_match = require("utils.util_match")
  12. local nodeMgr = require("nodeMgr")
  13. local timerDestroyRoom = nil
  14. local CMD = {}
  15. -- 关闭超时未开始战斗房间
  16. local function _destroy_room()
  17. local activeRoomIdList = util_match:get_active_room_id_list()
  18. if is_empty(activeRoomIdList) then
  19. return
  20. end
  21. for _, v in ipairs(activeRoomIdList) do
  22. local roomId = tonumber(v)
  23. -- 是否等待开始战斗结束
  24. if util_match:is_wait_battle_end(roomId) then
  25. -- 通知在线玩家 - 销毁房间
  26. nodeMgr.broadcast_proto_notify("on_room_destroy", {roomId = roomId})
  27. -- 删除房间信息
  28. util_match:destroy_room(roomId)
  29. end
  30. end
  31. end
  32. function CMD.onStart()
  33. timerDestroyRoom = timer.timeOut(1, _destroy_room)
  34. end
  35. function CMD.onStop()
  36. -- 取消定时器
  37. timerDestroyRoom.func = nil
  38. end
  39. baseService.start(CMD, ".srvMatch", true)