添加工会消息转发

This commit is contained in:
aozhiwei 2020-09-15 11:25:06 +08:00
parent c27567da9e
commit b665f4aafa
10 changed files with 59 additions and 6 deletions

View File

@ -23,6 +23,7 @@ include_directories(
/usr/include/glm
../../third_party
../../third_party/behaviac/inc
../../third_party/recastnavigation/Recast/Include
../../third_party/recastnavigation/Detour/Include
../../third_party/recastnavigation/DetourTileCache/Include
.
@ -46,6 +47,10 @@ aux_source_directory(../../third_party/recastnavigation/Detour/Source
SRC_LIST
)
aux_source_directory(../../third_party/recastnavigation/Recast/Source
SRC_LIST
)
aux_source_directory(../../third_party/recastnavigation/DetourTileCache/Source
SRC_LIST
)

View File

@ -25,6 +25,12 @@ IMConn* IMConnMgr::GetConnByKey(const std::string& key)
return itr != key_hash_.end() ? itr->second : nullptr;
}
IMConn* IMConnMgr::GetConnByInstanceId(long long instance_id)
{
auto itr = id_hash_.find(instance_id);
return itr != id_hash_.end() ? itr->second : nullptr;
}
IMConn* IMConnMgr::RecreateIMConn(const std::string& host, int port)
{
std::string key = host + ":" + a8::XValue(port).GetString();

View File

@ -27,6 +27,7 @@ class IMConnMgr : public a8::Singleton<IMConnMgr>
void _SS_Pong(f8::MsgHdr& hdr, const ss::SS_Pong& msg);
IMConn* GetConnByKey(const std::string& key);
IMConn* GetConnByInstanceId(long long instance_id);
IMConn* RecreateIMConn(const std::string& host, int port);
void TraverseIMConn(std::function<bool (IMConn*)> func);

View File

@ -22,7 +22,7 @@ void GuildMgr::_SS_MS_LoadGuild(f8::MsgHdr& hdr, const ss::SS_MS_LoadGuild& msg)
}
void GuildMgr::_SS_MS_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_MS_ForwardGuildCMMsg& msg)
void GuildMgr::_SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_ForwardGuildCMMsg& msg)
{
switch (hdr.msgid) {
case cs::CMMessageId_e::_CMGuildCreate:
@ -230,7 +230,7 @@ Guild* GuildMgr::GetGuild(long long guild_id)
void GuildMgr::ForwardGuildSMMsg(const ss::MFIMMsgConext& context,
const ::google::protobuf::Message& smmsg)
{
ss::SS_MS_ForwardGuildSMMsg msg;
ss::SS_IM_ForwardGuildSMMsg msg;
*msg.mutable_context() = context;
smmsg.SerializeToString(msg.mutable_payload());
MSConnMgr::Instance()->SendMsg(msg, 0);

View File

@ -15,7 +15,7 @@ namespace ss
{
class MFIMMsgConext;
class SS_MS_LoadGuild;
class SS_MS_ForwardGuildCMMsg;
class SS_IM_ForwardGuildCMMsg;
}
namespace google
@ -41,7 +41,7 @@ class GuildMgr : public a8::Singleton<GuildMgr>
void UnInit();
void _SS_MS_LoadGuild(f8::MsgHdr& hdr, const ss::SS_MS_LoadGuild& msg);
void _SS_MS_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_MS_ForwardGuildCMMsg& msg);
void _SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_ForwardGuildCMMsg& msg);
private:
void _CMGuildCreate(const ss::MFIMMsgConext& context, const cs::CMGuildCreate& msg);

View File

@ -96,6 +96,8 @@ void HandlerMgr::RegisterNetMsgHandlers()
RegisterNetMsgHandler(&wsmsghandler, &Player::_CMGroupDismiss);
RegisterNetMsgHandler(&wsmsghandler, &Player::_CMGroupRename);
RegisterNetMsgHandler(&immsghandler, &GuildMgr::_SS_IM_ForwardGuildCMMsg);
RegisterNetMsgHandler(&wsmsghandler, &Player::_CMGuildCreate);
RegisterNetMsgHandler(&wsmsghandler, &Player::_CMGuildJoin);
RegisterNetMsgHandler(&wsmsghandler, &Player::_CMGuildAgree);

View File

@ -174,3 +174,31 @@ void SyncHelper::SS_IM_FriendDeleteRequest_TimeOut(ss::SS_IM_FriendDeleteRequest
event_data
);
}
void SyncHelper::SendIMConnMsg(int instance_id, int msgid, ::google::protobuf::Message& msg)
{
IMConn* conn = IMConnMgr::Instance()->GetConnByInstanceId(instance_id);
if (conn) {
conn->SendMsg(msgid, msg);
} else {
int packlen = msg.ByteSize();
char* buff = nullptr;
if (packlen > 0) {
buff = (char*)malloc(packlen);
msg.SerializeToArray(buff, packlen);
}
App::Instance()->AddSocketMsg
(
SF_IMConn,
0,
0,
msgid,
0,
buff,
packlen
);
if (buff) {
free(buff);
}
}
}

View File

@ -47,5 +47,14 @@ public:
void BroadcastIMConnMsg(int msgid, ::google::protobuf::Message& msg);
template <typename T>
void SendIMConnMsg(int intance_id, T& msg)
{
static int msgid = f8::Net_GetMessageId(msg);
SendIMConnMsg(msgid, msg);
}
void SendIMConnMsg(int intance_id, int msgid, ::google::protobuf::Message& msg);
std::map<long long, timer_list*> pending_request_hash_;
};

View File

@ -41,4 +41,6 @@ enum SSMessageId_e
_SS_IM_OnUserOffline = 1024;
_SS_IM_RandomUsersRequest = 1025;
_SS_IM_RandomUsersResponse = 1026;
_SS_IM_ForwardGuildCMMsg = 1027;
_SS_IM_ForwardGuildSMMsg = 1028;
}

View File

@ -151,13 +151,13 @@ message SS_MS_LoadGroup
optional int64 group_id = 1;
}
message SS_MS_ForwardGuildCMMsg
message SS_IM_ForwardGuildCMMsg
{
optional MFIMMsgConext context = 1;
optional bytes payload = 2;
}
message SS_MS_ForwardGuildSMMsg
message SS_IM_ForwardGuildSMMsg
{
optional MFIMMsgConext context = 1;
optional bytes payload = 2;