数据统计ok

This commit is contained in:
aozhiwei 2019-05-24 15:03:17 +08:00
parent 8668493053
commit 7a9332375b
4 changed files with 21 additions and 10 deletions

View File

@ -59,7 +59,7 @@ static void SavePerfLog()
RoomMgr::Instance()->RoomNum() RoomMgr::Instance()->RoomNum()
}); });
if (App::Instance()->HasFlag(4)) { if (App::Instance()->HasFlag(4)) {
a8::XPrintf("max_mainloop_rundelay:%d max_dispatchmsg_time:%d room_num:%d online_num:%d\n", a8::XPrintf("mainloop_time:%d netmsg_time:%d room:%d online:%d\n",
{ {
App::Instance()->perf.max_run_delay_time, App::Instance()->perf.max_run_delay_time,
App::Instance()->perf.max_dispatchmsg_time, App::Instance()->perf.max_dispatchmsg_time,

View File

@ -1147,6 +1147,7 @@ void Room::OnGameOver()
pair.second->SendGameOver(); pair.second->SendGameOver();
} }
} }
RoomMgr::Instance()->AddOverRoom(room_uuid);
} }
void Room::RandRemoveAndroid() void Room::RandRemoveAndroid()

View File

@ -131,11 +131,6 @@ int RoomMgr::RoomNum()
return room_hash_.size(); return room_hash_.size();
} }
int RoomMgr::ActiveRoomNum()
{
return room_hash_.size() - over_room_hash_.size();
}
Room* RoomMgr::GetJoinableRoom(const std::string& account_id) Room* RoomMgr::GetJoinableRoom(const std::string& account_id)
{ {
for (auto& pair : inactive_room_hash_) { for (auto& pair : inactive_room_hash_) {
@ -146,12 +141,27 @@ Room* RoomMgr::GetJoinableRoom(const std::string& account_id)
return nullptr; return nullptr;
} }
Room* RoomMgr::GetRoomByUuid(long long uuid) Room* RoomMgr::GetRoomByUuid(long long room_uuid)
{ {
auto itr = room_hash_.find(uuid); auto itr = room_hash_.find(room_uuid);
return itr != room_hash_.end() ? itr->second : nullptr; return itr != room_hash_.end() ? itr->second : nullptr;
} }
void RoomMgr::AddOverRoom(long long room_uuid)
{
a8::Timer::Instance()->AddDeadLineTimer(1000,
a8::XParams()
.SetSender(room_uuid),
[] (const a8::XParams& param)
{
Room* room = RoomMgr::Instance()->GetRoomByUuid(param.sender);
if (room) {
RoomMgr::Instance()->room_hash_.erase(room->room_uuid);
RoomMgr::Instance()->over_room_hash_[room->room_uuid] = room;
}
});
}
void RoomMgr::RemoveFromInactiveRoomHash(long long room_uuid) void RoomMgr::RemoveFromInactiveRoomHash(long long room_uuid)
{ {
inactive_room_hash_.erase(room_uuid); inactive_room_hash_.erase(room_uuid);
@ -169,7 +179,7 @@ void RoomMgr::ReportServerState(int instance_id, const std::string& host, int po
url_params->SetVal("ip", JsonDataMgr::Instance()->ip); url_params->SetVal("ip", JsonDataMgr::Instance()->ip);
url_params->SetVal("port", JsonDataMgr::Instance()->listen_port); url_params->SetVal("port", JsonDataMgr::Instance()->listen_port);
url_params->SetVal("online_num", PlayerMgr::Instance()->OnlineNum()); url_params->SetVal("online_num", PlayerMgr::Instance()->OnlineNum());
url_params->SetVal("room_num", ActiveRoomNum()); url_params->SetVal("room_num", RoomNum());
f8::HttpClientPool::Instance()->HttpGet(a8::XParams() f8::HttpClientPool::Instance()->HttpGet(a8::XParams()
.SetSender(instance_id) .SetSender(instance_id)
.SetParam1(host) .SetParam1(host)

View File

@ -23,8 +23,8 @@ class RoomMgr : public a8::Singleton<RoomMgr>
void _CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg); void _CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg);
void RemoveFromInactiveRoomHash(long long room_uuid); void RemoveFromInactiveRoomHash(long long room_uuid);
int RoomNum(); int RoomNum();
int ActiveRoomNum();
Room* GetRoomByUuid(long long uuid); Room* GetRoomByUuid(long long uuid);
void AddOverRoom(long long room_uuid);
private: private:
Room* GetJoinableRoom(const std::string& account_id); Room* GetJoinableRoom(const std::string& account_id);