From f2d751f39641f15f67c707e84b9b2085e23f3d19 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 18 May 2019 15:24:39 +0800 Subject: [PATCH] 1 --- server/gameserver/roommgr.cc | 35 +++++++++++++++++++++++++++++++---- server/gameserver/roommgr.h | 2 +- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 875a686..1ec5901 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -157,7 +157,7 @@ void RoomMgr::RemoveFromInactiveRoomHash(long long room_uuid) inactive_room_hash_.erase(room_uuid); } -void RoomMgr::ReportServerState(int instanc_id, const std::string& host, int port) +void RoomMgr::ReportServerState(int instance_id, const std::string& host, int port) { std::string url = a8::Format("http://%s:%d/webapp/index.php?", { @@ -170,14 +170,41 @@ void RoomMgr::ReportServerState(int instanc_id, const std::string& host, int por url_params->SetVal("port", JsonDataMgr::Instance()->listen_port); url_params->SetVal("online_num", PlayerMgr::Instance()->OnlineNum()); url_params->SetVal("room_num", ActiveRoomNum()); - f8::HttpClientPool::Instance()->HttpGet(a8::XParams(), + f8::HttpClientPool::Instance()->HttpGet(a8::XParams() + .SetSender(instance_id) + .SetParam1(host) + .SetParam2(port), [] (a8::XParams& param, a8::XObject& data) { - + a8::Timer::Instance()->AddDeadLineTimer(1000, + a8::XParams() + .SetSender(param.sender) + .SetParam1(param.param1) + .SetParam2(param.param2), + [] (const a8::XParams& param) + { + RoomMgr::Instance()->ReportServerState( + param.sender, + param.param1, + param.param2 + ); + }); }, [] (a8::XParams& param, const std::string& response) { - + a8::Timer::Instance()->AddDeadLineTimer(1000, + a8::XParams() + .SetSender(param.sender) + .SetParam1(param.param1) + .SetParam2(param.param2), + [] (const a8::XParams& param) + { + RoomMgr::Instance()->ReportServerState( + param.sender, + param.param1, + param.param2 + ); + }); }, url.c_str(), *url_params, diff --git a/server/gameserver/roommgr.h b/server/gameserver/roommgr.h index 9478223..aa5603c 100644 --- a/server/gameserver/roommgr.h +++ b/server/gameserver/roommgr.h @@ -28,7 +28,7 @@ class RoomMgr : public a8::Singleton private: Room* GetJoinableRoom(const std::string& account_id); - void ReportServerState(int instanc_id, const std::string& host, int port); + void ReportServerState(int instance_id, const std::string& host, int port); private: std::map inactive_room_hash_;