srvMatch.lua 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 timerDestroyRoom = nil
  13. local CMD = {}
  14. -- 关闭超时未开始战斗房间
  15. local function _destroy_room()
  16. local activeRoomIdList = util_match:get_active_room_id_list()
  17. if is_empty(activeRoomIdList) then
  18. return
  19. end
  20. for _, v in ipairs(activeRoomIdList) do
  21. local roomId = tonumber(v)
  22. -- 是否等待开始战斗结束
  23. if util_match:is_wait_battle_end(roomId) then
  24. -- TODO:通知在线玩家 - 销毁房间
  25. -- 删除房间信息
  26. util_match:destroy_room(roomId)
  27. end
  28. end
  29. end
  30. function CMD.onStart()
  31. timerDestroyRoom = timer.timeOut(1, _destroy_room)
  32. end
  33. function CMD.onStop()
  34. -- 取消定时器
  35. timerDestroyRoom.func = nil
  36. end
  37. baseService.start(CMD, ".srvMatch", true)