From 6808386408e28ab90b1d47bec6df73acb468f1af Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 30 May 2019 10:09:59 +0800 Subject: [PATCH] add stopservice startservice api --- server/gameserver/app.h | 3 +++ server/gameserver/handlermgr.cc | 26 +++++++++++++++++++++++++- server/gameserver/roommgr.cc | 1 + 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/server/gameserver/app.h b/server/gameserver/app.h index 0899486..10e2a9a 100644 --- a/server/gameserver/app.h +++ b/server/gameserver/app.h @@ -63,6 +63,9 @@ public: int instance_id = 0; bool is_test_mode = false; int test_param = 0; + bool servicing = true; + +private: /* 1: 是否自动匹配机器人组队 2: 是否发布环境 diff --git a/server/gameserver/handlermgr.cc b/server/gameserver/handlermgr.cc index 043bd6e..b844f6e 100644 --- a/server/gameserver/handlermgr.cc +++ b/server/gameserver/handlermgr.cc @@ -18,6 +18,7 @@ static void _GMOpsSelfChecking(f8::JsonHttpRequest* request) request->resp_xobj->SetVal("errcode", 0); request->resp_xobj->SetVal("errmsg", ""); request->resp_xobj->SetVal("healthy", 1); + request->resp_xobj->SetVal("servicing", App::Instance()->servicing ? 1 : 0); request->resp_xobj->SetVal("max_rundelay", App::Instance()->perf.max_run_delay_time); request->resp_xobj->SetVal("max_timer_idle", App::Instance()->perf.max_timer_idle); } @@ -30,12 +31,35 @@ static void _GMOpsReload(f8::JsonHttpRequest* request) a8::UdpLog::Instance()->Warning("reload config files", {}); } +static void _GMOpsStopService(f8::JsonHttpRequest* request) +{ + request->resp_xobj->SetVal("errcode", 0); + request->resp_xobj->SetVal("errmsg", ""); + App::Instance()->servicing = false; +} + +static void _GMOpsStartService(f8::JsonHttpRequest* request) +{ + request->resp_xobj->SetVal("errcode", 0); + request->resp_xobj->SetVal("errmsg", ""); + App::Instance()->servicing = true; +} + +static void _GMOpsOnlineUserNum(f8::JsonHttpRequest* request) +{ + request->resp_xobj->SetVal("errcode", 0); + request->resp_xobj->SetVal("errmsg", ""); + request->resp_xobj->SetVal("user_num", App::Instance()->perf.entity_num[ET_Player]); +} + void HandlerMgr::Init() { RegisterNetMsgHandlers(); RegisterGMMsgHandler("Ops@selfChecking", _GMOpsSelfChecking); RegisterGMMsgHandler("Ops@reload", _GMOpsReload); - // RegisterGMMsgHandler("Ops@shutdown", _GMOpsShutdown); + RegisterGMMsgHandler("Ops@stopService", _GMOpsStopService); + RegisterGMMsgHandler("Ops@startService", _GMOpsStartService); + RegisterGMMsgHandler("Ops@onlineUserNum", _GMOpsOnlineUserNum); } void HandlerMgr::UnInit() diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index fc230da..243de22 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -200,6 +200,7 @@ void RoomMgr::ReportServerState(int instance_id, const std::string& host, int po url_params->SetVal("port", JsonDataMgr::Instance()->listen_port); url_params->SetVal("online_num", PlayerMgr::Instance()->OnlineNum()); url_params->SetVal("room_num", RoomNum()); + url_params->SetVal("servicing", App::Instance()->servicing ? 1 : 0); f8::HttpClientPool::Instance()->HttpGet(a8::XParams() .SetSender(instance_id) .SetParam1(host)