game2006/server/gameserver/matchpool.cc
aozhiwei c144c7a803 1
2022-12-17 15:25:05 +08:00

73 lines
1.4 KiB
C++

#include "precompile.h"
#include <f8/timer.h>
#include "cs_proto.pb.h"
#include "matchpool.h"
#include "GGListener.h"
#include "matchteamnew.h"
void MatchPool::Init()
{
f8::Timer::Instance()->SetIntervalEx
(1000,
[] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
MatchPool::Instance()->Update();
}
},
&timer_attacher_);
}
void MatchPool::UnInit()
{
}
void MatchPool::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
{
}
MatchTeamNew* MatchPool::GetTeam(const std::string& team_uuid)
{
auto itr = team_hash_.find(team_uuid);
return itr != team_hash_.end() ? itr->second : nullptr;
}
void MatchPool::TraverseTeam(std::function<void (MatchTeamNew*, bool&)> func)
{
if (!func) {
return;
}
bool stop = false;
for (auto& pair : team_hash_) {
if (pair.second) {
func(pair.second, stop);
if (stop){
return;
}
}
}
}
void MatchPool::RemoveTeam(const std::string& team_uuid)
{
auto itr = team_hash_.find(team_uuid);
if (itr != team_hash_.end()) {
delete itr->second;
team_hash_.erase(itr);
}
}
void MatchPool::RemoveSocket(int socket_handle)
{
auto itr = socket_hash_.find(socket_handle);
if (itr != socket_hash_.end()) {
socket_hash_.erase(itr);
}
}
void MatchPool::Update()
{
}