diff --git a/script/constant.lua b/script/constant.lua index ab625577..b2a15a1b 100644 --- a/script/constant.lua +++ b/script/constant.lua @@ -91,10 +91,8 @@ GMType.GLOBAL = 0 -- 全局相关 GMType.PLAYER = 1 -- 玩家相关, ID为玩家的ID GMType.SERVICE = 2 -- 服务相关, 转发所有服务 GMType.SYSTEM = 3 -- 业务相关, ID为队伍ID,房间ID等 -GMType.OFFLINE = 4 -- 玩家相关, ID为玩家的ID,需要处理离线 -GMType.LOCAL = 5 -- 本地事件转发 -GMType.HASHKEY = 6 -- 服务相关, ID按hash分发 - +GMType.LOCAL = 4 -- 本地事件转发 +GMType.HASHKEY = 5 -- 服务相关, ID按hash分发 -- robot类型 local RobotType = enum("RobotType", 0) diff --git a/server/center/gm_mgr.lua b/server/center/gm_mgr.lua index 1cf59d5e..93197e58 100644 --- a/server/center/gm_mgr.lua +++ b/server/center/gm_mgr.lua @@ -8,13 +8,11 @@ local log_err = logger.err local log_debug = logger.debug local sformat = string.format local tunpack = table.unpack -local tinsert = table.insert local make_sid = service.make_sid local guid_index = codec.guid_index local online = quanta.get("online") local cmdline = quanta.get("cmdline") -local monitor = quanta.get("monitor") local event_mgr = quanta.get("event_mgr") local update_mgr = quanta.get("update_mgr") local router_mgr = quanta.get("router_mgr") @@ -22,18 +20,15 @@ local router_mgr = quanta.get("router_mgr") local GLOBAL = quanta.enum("GMType", "GLOBAL") local SYSTEM = quanta.enum("GMType", "SYSTEM") local SERVICE = quanta.enum("GMType", "SERVICE") -local OFFLINE = quanta.enum("GMType", "OFFLINE") local LOCAL = quanta.enum("GMType", "LOCAL") local HASHKEY = quanta.enum("GMType", "HASHKEY") local PLAYER = quanta.enum("GMType", "PLAYER") local SUCCESS = quanta.enum("KernCode", "SUCCESS") -local PLAYER_NOT_EXIST = quanta.enum("KernCode", "PLAYER_NOT_EXIST") local GM_Mgr = singleton() local prop = property(GM_Mgr) prop:reader("http_server", nil) prop:reader("services", {}) -prop:reader("monitors", {}) prop:reader("gm_page", "") prop:reader("gm_status", false) @@ -52,9 +47,6 @@ function GM_Mgr:__init() self.gm_status = true self:register_webgm() end - --关注monitor - monitor:watch_service_ready(self, "monitor") - monitor:watch_service_close(self, "monitor") --定时更新 update_mgr:attach_second5(self) self:on_second5() @@ -80,16 +72,9 @@ function GM_Mgr:on_second5() self.gm_page = import("center/gm_page.lua") end --- 事件请求 -function GM_Mgr:on_register_command(command_list, service_id) - self:rpc_register_command(command_list, service_id) - return SUCCESS -end - function GM_Mgr:register_webgm() self:register_get("/", "on_gm_page", self) self:register_get("/gmlist", "on_gmlist", self) - self:register_get("/monitors", "on_monitors", self) self:register_post("/command", "on_command", self) self:register_post("/message", "on_message", self) end @@ -167,16 +152,6 @@ function GM_Mgr:on_gmlist(url, body, params) return { text = "GM指令", nodes = cmdline:get_displays() } end ---monitor拉取 -function GM_Mgr:on_monitors(url, body, params) - log_debug("[GM_Mgr][on_monitors] body: {}", params) - local nodes = {} - for _, addr in pairs(self.monitors) do - tinsert(nodes, { text = addr, tag = "log" }) - end - return { text = "在线日志", nodes = nodes } -end - --后台GM调用,字符串格式 function GM_Mgr:on_command(url, body) log_debug("[GM_Mgr][on_command] body: {}", body) @@ -228,7 +203,6 @@ function GM_Mgr:dispatch_command(cmd_args, gm_type, service_id) [SYSTEM] = GM_Mgr.exec_system_cmd, [PLAYER] = GM_Mgr.exec_player_cmd, [SERVICE] = GM_Mgr.exec_service_cmd, - [OFFLINE] = GM_Mgr.exec_offline_cmd, [LOCAL] = GM_Mgr.exec_local_cmd, [HASHKEY] = GM_Mgr.exec_hash_cmd, } @@ -286,25 +260,6 @@ function GM_Mgr:exec_local_cmd(service_id, cmd_name, ...) return { code = 0, msg = res } end ---兼容在线和离线的玩家指令 -function GM_Mgr:exec_offline_cmd(service_id, cmd_name, player_id, ...) - log_debug("[GM_Mgr][exec_offline_cmd] cmd_name:{} player_id:{}", cmd_name, player_id) - local ok, codeoe, res = online:call_lobby(player_id, "rpc_command_execute", cmd_name, player_id, ...) - if not ok then - log_err("[GM_Mgr][exec_offline_cmd] rpc_command_execute failed! cmd_name={} player_id={}", cmd_name, player_id) - return { code = 1, msg = codeoe } - end - if codeoe == PLAYER_NOT_EXIST then - ok, codeoe, res = router_mgr:call_lobby_hash(player_id, "rpc_command_execute", cmd_name, player_id, ...) - if not ok then - log_err("[GM_Mgr][exec_offline_cmd] rpc_command_execute failed! player_id:{}, cmd_name={}", player_id, cmd_name) - return { code = 1, msg = codeoe } - end - return { code = codeoe, msg = res } - end - return { code = codeoe, msg = res } -end - --player command function GM_Mgr:exec_player_cmd(service_id, cmd_name, player_id, ...) if player_id == 0 then diff --git a/server/test/mongo_test.lua b/server/test/mongo_test.lua index 56a55f7c..9da73028 100644 --- a/server/test/mongo_test.lua +++ b/server/test/mongo_test.lua @@ -34,7 +34,7 @@ timer_mgr:once(2000, function() log_debug("db listIndexes code: {}, err = {}", icode, ierr) icode, ierr = mongo_mgr:drop_indexes("test_mongo_2", "test_uid") log_debug("db drop_indexes code: {}, err = {}", icode, ierr) - + icode, ierr = mongo_mgr:create_indexes("test_mongo_3", {{key={"pid",1,"uid",1},name="test_uid", unique = true}}) log_debug("db create_indexes code: {}, err = {}", icode, ierr) icode, ierr = mongo_mgr:create_indexes("test_mongo_3", { { key = { ttl = 1 }, expireAfterSeconds = 0, name = "ttl", unique = false } })