1
This commit is contained in:
parent
3afaa7a2cb
commit
bffe371015
@ -39,17 +39,26 @@ void MatchMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
|||||||
|
|
||||||
void MatchMgr::_CMMatchCancel(f8::MsgHdr& hdr, const cs::CMMatchCancel& 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)
|
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)
|
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)
|
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;
|
||||||
|
}
|
||||||
|
@ -31,8 +31,9 @@ public:
|
|||||||
|
|
||||||
bool NeedMatch(const cs::CMJoin& msg);
|
bool NeedMatch(const cs::CMJoin& msg);
|
||||||
MatchTeam* GetTeam(const std::string& team_uuid);
|
MatchTeam* GetTeam(const std::string& team_uuid);
|
||||||
|
std::tuple<std::string, MatchTeam*>* GetMatchInfo(int socket_handle);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<std::string, MatchTeam*> team_hash_;
|
std::map<std::string, MatchTeam*> team_hash_;
|
||||||
std::map<int, std::string> socket_hash_;
|
std::map<int, std::tuple<std::string, MatchTeam*>> socket_hash_;
|
||||||
};
|
};
|
||||||
|
@ -42,6 +42,21 @@ void MatchTeam::Init(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
|||||||
AddRawMember(hdr, 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)
|
void MatchTeam::AddRawMember(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||||
{
|
{
|
||||||
std::shared_ptr<RawTeamMember> member = std::make_shared<RawTeamMember>();
|
std::shared_ptr<RawTeamMember> member = std::make_shared<RawTeamMember>();
|
||||||
|
@ -21,6 +21,11 @@ class MatchTeam
|
|||||||
a8::TimerAttacher timer_attacher;
|
a8::TimerAttacher timer_attacher;
|
||||||
|
|
||||||
void Init(f8::MsgHdr& hdr, const cs::CMJoin& msg);
|
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);
|
void AddRawMember(f8::MsgHdr& hdr, const cs::CMJoin& msg);
|
||||||
bool IsRawMember(const std::string& account_id);
|
bool IsRawMember(const std::string& account_id);
|
||||||
bool IsValidMember(const cs::CMJoin& msg);
|
bool IsValidMember(const cs::CMJoin& msg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user