添加匹配时组队内成员消息

This commit is contained in:
aozhiwei 2021-11-26 15:36:40 +08:00
parent cacbbab1d0
commit bba1e6ba8e
6 changed files with 90 additions and 4 deletions

View File

@ -95,6 +95,22 @@ void MatchMgr::_CMMatchCancelStartGame(f8::MsgHdr& hdr, const cs::CMMatchCancelS
} }
} }
void MatchMgr::_CMMatchSendMsg(f8::MsgHdr& hdr, const cs::CMMatchSendMsg& msg)
{
auto match_info = GetMatchInfo(hdr.socket_handle);
if (match_info) {
std::get<1>(*match_info)->_CMMatchSendMsg(hdr, msg);
}
}
void MatchMgr::_CMMatchBroadcastMsg(f8::MsgHdr& hdr, const cs::CMMatchBroadcastMsg& msg)
{
auto match_info = GetMatchInfo(hdr.socket_handle);
if (match_info) {
std::get<1>(*match_info)->_CMMatchBroadcastMsg(hdr, msg);
}
}
bool MatchMgr::NeedMatch(const cs::CMJoin& msg) bool MatchMgr::NeedMatch(const cs::CMJoin& msg)
{ {
bool need = !msg.team_uuid().empty() && bool need = !msg.team_uuid().empty() &&

View File

@ -8,6 +8,8 @@ namespace cs
class CMMatchChoose; class CMMatchChoose;
class CMMatchStartGame; class CMMatchStartGame;
class CMMatchCancelStartGame; class CMMatchCancelStartGame;
class CMMatchSendMsg;
class CMMatchBroadcastMsg;
} }
class MatchTeam; class MatchTeam;
@ -31,6 +33,8 @@ public:
void _CMMatchChoose(f8::MsgHdr& hdr, const cs::CMMatchChoose& msg); void _CMMatchChoose(f8::MsgHdr& hdr, const cs::CMMatchChoose& msg);
void _CMMatchStartGame(f8::MsgHdr& hdr, const cs::CMMatchStartGame& msg); void _CMMatchStartGame(f8::MsgHdr& hdr, const cs::CMMatchStartGame& msg);
void _CMMatchCancelStartGame(f8::MsgHdr& hdr, const cs::CMMatchCancelStartGame& msg); void _CMMatchCancelStartGame(f8::MsgHdr& hdr, const cs::CMMatchCancelStartGame& msg);
void _CMMatchSendMsg(f8::MsgHdr& hdr, const cs::CMMatchSendMsg& msg);
void _CMMatchBroadcastMsg(f8::MsgHdr& hdr, const cs::CMMatchBroadcastMsg& msg);
void TraverseTeam(std::function<void (MatchTeam*, bool&)> func); void TraverseTeam(std::function<void (MatchTeam*, bool&)> func);
bool NeedMatch(const cs::CMJoin& msg); bool NeedMatch(const cs::CMJoin& msg);

View File

@ -94,10 +94,6 @@ void MatchTeam::Init(f8::MsgHdr& hdr, const cs::CMJoin& msg)
void MatchTeam::_CMMatchCancel(f8::MsgHdr& hdr, const cs::CMMatchCancel& msg) void MatchTeam::_CMMatchCancel(f8::MsgHdr& hdr, const cs::CMMatchCancel& msg)
{ {
auto member = GetMemberBySocket(hdr.socket_handle);
if (member) {
}
} }
void MatchTeam::_CMMatchChoose(f8::MsgHdr& hdr, const cs::CMMatchChoose& msg) void MatchTeam::_CMMatchChoose(f8::MsgHdr& hdr, const cs::CMMatchChoose& msg)
@ -158,6 +154,48 @@ void MatchTeam::_CMMatchCancelStartGame(f8::MsgHdr& hdr, const cs::CMMatchCancel
} }
} }
void MatchTeam::_CMMatchSendMsg(f8::MsgHdr& hdr, const cs::CMMatchSendMsg& msg)
{
auto sender = GetMemberBySocket(hdr.socket_handle);
if (sender) {
for (auto member : master_team_->curr_member_hash_) {
if (member->socket_handle != 0) {
bool found = false;
for (auto& target : msg.target_list()) {
if (target == member->msg.account_id()) {
found = true;
break;
}
}
if (found) {
cs::SMMatchMemberMsgNotify notifymsg;
notifymsg.set_sender(sender->msg.account_id());
notifymsg.set_content(msg.content());
GGListener::Instance()->SendToClient(member->socket_handle, 0, notifymsg);
}
}
}
}
}
void MatchTeam::_CMMatchBroadcastMsg(f8::MsgHdr& hdr, const cs::CMMatchBroadcastMsg& msg)
{
auto sender = GetMemberBySocket(hdr.socket_handle);
if (sender) {
for (auto member : master_team_->curr_member_hash_) {
if (member->socket_handle != 0) {
if (!msg.exclude_self() ||
(msg.exclude_self() && sender->msg.account_id() != member->msg.account_id())) {
cs::SMMatchMemberMsgNotify notifymsg;
notifymsg.set_sender(sender->msg.account_id());
notifymsg.set_content(msg.content());
GGListener::Instance()->SendToClient(member->socket_handle, 0, notifymsg);
}
}
}
}
}
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>();

View File

@ -54,6 +54,8 @@ class MatchTeam
void _CMMatchChoose(f8::MsgHdr& hdr, const cs::CMMatchChoose& msg); void _CMMatchChoose(f8::MsgHdr& hdr, const cs::CMMatchChoose& msg);
void _CMMatchStartGame(f8::MsgHdr& hdr, const cs::CMMatchStartGame& msg); void _CMMatchStartGame(f8::MsgHdr& hdr, const cs::CMMatchStartGame& msg);
void _CMMatchCancelStartGame(f8::MsgHdr& hdr, const cs::CMMatchCancelStartGame& msg); void _CMMatchCancelStartGame(f8::MsgHdr& hdr, const cs::CMMatchCancelStartGame& msg);
void _CMMatchSendMsg(f8::MsgHdr& hdr, const cs::CMMatchSendMsg& msg);
void _CMMatchBroadcastMsg(f8::MsgHdr& hdr, const cs::CMMatchBroadcastMsg& 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);

View File

@ -25,6 +25,8 @@ enum CMMessageId_e
_CMMatchChoose = 219; _CMMatchChoose = 219;
_CMMatchStartGame = 220; _CMMatchStartGame = 220;
_CMMatchCancelStartGame = 221; _CMMatchCancelStartGame = 221;
_CMMatchSendMsg = 222;
_CMMatchBroadcastMsg = 223;
} }
enum SMMessageId_e enum SMMessageId_e
@ -56,4 +58,5 @@ enum SMMessageId_e
_SMShowTeamUI = 1016; _SMShowTeamUI = 1016;
_SMUpdateMatchInfo = 1017; _SMUpdateMatchInfo = 1017;
_SMGetItemNotify = 1018; _SMGetItemNotify = 1018;
_SMMatchMemberMsgNotify = 1019;
} }

View File

@ -1134,6 +1134,22 @@ message CMMatchCancelStartGame
{ {
} }
//-
message CMMatchSendMsg
{
//SMMatchMemberMsgNotify消息
repeated string target_list = 1; //,SMMatchMemberMsgNotify消息
optional string content = 2; //
}
//-广
message CMMatchBroadcastMsg
{
//SMMatchMemberMsgNotify消息
optional int32 exclude_self = 1; //include_self!=0
optional string content = 2; //
}
//endcmmsg //endcmmsg
//error_code == 0 , //error_code == 0 ,
@ -1337,6 +1353,13 @@ message SMUpdateMatchInfo
optional MFMatchInfo info = 1; // optional MFMatchInfo info = 1; //
} }
//-
message SMMatchMemberMsgNotify
{
optional string sender = 1; //
optional string content = 2; //
}
// //
message SMGetItemNotify message SMGetItemNotify
{ {