This commit is contained in:
aozhiwei 2021-09-27 13:54:54 +00:00
parent 3afaa7a2cb
commit bffe371015
4 changed files with 40 additions and 4 deletions

View File

@ -39,17 +39,26 @@ void MatchMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
void MatchMgr::_CMMatchCancel(f8::MsgHdr& hdr, const cs::CMMatchCancel& msg)
{
auto match_info = GetMatchInfo(hdr.socket_handle);
if (match_info) {
std::get<1>(*match_info)->_CMMatchCancel(hdr, msg);
}
}
void MatchMgr::_CMMatchChoose(f8::MsgHdr& hdr, const cs::CMMatchChoose& msg)
{
auto match_info = GetMatchInfo(hdr.socket_handle);
if (match_info) {
std::get<1>(*match_info)->_CMMatchChoose(hdr, msg);
}
}
void MatchMgr::_CMMatchStartGame(f8::MsgHdr& hdr, const cs::CMMatchStartGame& msg)
{
auto match_info = GetMatchInfo(hdr.socket_handle);
if (match_info) {
std::get<1>(*match_info)->_CMMatchStartGame(hdr, msg);
}
}
bool MatchMgr::NeedMatch(const cs::CMJoin& msg)
@ -90,3 +99,9 @@ void MatchMgr::TraverseTeam(std::function<void (MatchTeam*, bool&)> func)
}
}
}
std::tuple<std::string, MatchTeam*>* MatchMgr::GetMatchInfo(int socket_handle)
{
auto itr = socket_hash_.find(socket_handle);
return itr != socket_hash_.end() ? &itr->second : nullptr;
}

View File

@ -31,8 +31,9 @@ public:
bool NeedMatch(const cs::CMJoin& msg);
MatchTeam* GetTeam(const std::string& team_uuid);
std::tuple<std::string, MatchTeam*>* GetMatchInfo(int socket_handle);
private:
std::map<std::string, MatchTeam*> team_hash_;
std::map<int, std::string> socket_hash_;
std::map<int, std::tuple<std::string, MatchTeam*>> socket_hash_;
};

View File

@ -42,6 +42,21 @@ void MatchTeam::Init(f8::MsgHdr& hdr, const cs::CMJoin& msg)
AddRawMember(hdr, msg);
}
void MatchTeam::_CMMatchCancel(f8::MsgHdr& hdr, const cs::CMMatchCancel& msg)
{
}
void MatchTeam::_CMMatchChoose(f8::MsgHdr& hdr, const cs::CMMatchChoose& msg)
{
}
void MatchTeam::_CMMatchStartGame(f8::MsgHdr& hdr, const cs::CMMatchStartGame& msg)
{
}
void MatchTeam::AddRawMember(f8::MsgHdr& hdr, const cs::CMJoin& msg)
{
std::shared_ptr<RawTeamMember> member = std::make_shared<RawTeamMember>();

View File

@ -21,6 +21,11 @@ class MatchTeam
a8::TimerAttacher timer_attacher;
void Init(f8::MsgHdr& hdr, const cs::CMJoin& msg);
void _CMMatchCancel(f8::MsgHdr& hdr, const cs::CMMatchCancel& msg);
void _CMMatchChoose(f8::MsgHdr& hdr, const cs::CMMatchChoose& msg);
void _CMMatchStartGame(f8::MsgHdr& hdr, const cs::CMMatchStartGame& msg);
void AddRawMember(f8::MsgHdr& hdr, const cs::CMJoin& msg);
bool IsRawMember(const std::string& account_id);
bool IsValidMember(const cs::CMJoin& msg);