game2006/server/gameserver/matchpool.h
aozhiwei 638084b3e7 1
2022-10-24 21:42:41 +08:00

41 lines
990 B
C++

#pragma once
namespace cs
{
class CMJoin;
}
class MatchTeamNew;
class TeamGroup;
class MatchPool : public a8::Singleton<MatchPool>
{
private:
MatchPool() {};
friend class a8::Singleton<MatchPool>;
public:
void Init();
void UnInit();
void _CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg);
private:
void TraverseTeam(std::function<void (MatchTeamNew*, bool&)> func);
bool NeedMatch(const cs::CMJoin& msg);
MatchTeamNew* GetTeam(const std::string& team_uuid);
void RemoveTeam(const std::string& team_uuid);
void RemoveSocket(int socket_handle);
void Update();
private:
a8::TimerAttacher timer_attacher_;
std::map<std::string, MatchTeamNew*> team_hash_;
std::map<int, std::tuple<std::string, MatchTeamNew*>> socket_hash_;
std::map<long long, std::shared_ptr<TeamGroup>> group_hash_;
std::map<long long, std::shared_ptr<TeamGroup>> matching_list_;
std::map<long long, std::shared_ptr<TeamGroup>> matchok_list_;
};