This commit is contained in:
aozhiwei 2020-09-27 11:17:52 +08:00
parent 9b0eb93c5e
commit fe3b364116
8 changed files with 46 additions and 3 deletions

View File

@ -50,6 +50,12 @@ class WSListener : public a8::Singleton<WSListener>
#endif
}
void SendRawDataToClient(int sockhandle, int msgid, const std::string& data)
{
f8::Net_SendProxyMsg(tcp_listener_, sockhandle, 0, 0, msgid, data);
++PerfMonitor::Instance()->send_ws_count;
}
void SendText(unsigned short sockhandle, const std::string& text);
void ForceCloseClient(unsigned short sockhandle);
void MarkClient(unsigned short sockhandle, bool is_active);

View File

@ -6,6 +6,7 @@
#include "guild.h"
#include "guildmgr.h"
#include "cs_msgid.pb.h"
#include "ss_msgid.pb.h"
#include "cs_proto.pb.h"
#include "ss_proto.pb.h"
#include "IMListener.h"
@ -96,6 +97,15 @@ void GuildMgr::_SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_Forward
CreateAsyncTask(hdr.socket_handle, msg.guild_id(), task);
}
void GuildMgr::_SS_IM_ForwardGuildSMMsg(f8::MsgHdr& hdr, const ss::SS_IM_ForwardGuildSMMsg& msg)
{
Player* hum = PlayerMgr::Instance()->GetPlayerByAccountId
(msg.context().user_info().base_data().account_id());
if (hum) {
WSListener::Instance()->SendRawDataToClient(hum->socket_handle, msg.msgid(), msg.payload());
}
}
void GuildMgr::CreateAsyncTask(int socket_handle, long long guild_id, AsyncGuildTask* task)
{
Guild* guild = GetGuild(guild_id);
@ -225,5 +235,27 @@ void GuildMgr::ForwardGuildSMMsg(int socket_handle,
*msg.mutable_context() = context;
msg.set_msgid(msgid);
smmsg.SerializeToString(msg.mutable_payload());
IMListener::Instance()->SendMsg(socket_handle, msg);
if (socket_handle == 0) {
int packlen = msg.ByteSize();
char* buff = nullptr;
if (packlen > 0) {
buff = (char*)malloc(packlen);
msg.SerializeToArray(buff, packlen);
}
App::Instance()->AddSocketMsg
(
SF_IMServer,
0,
0,
ss::SSMessageId_e::_SS_IM_ForwardGuildSMMsg,
0,
buff,
packlen
);
if (buff) {
free(buff);
}
} else {
IMListener::Instance()->SendMsg(socket_handle, msg);
}
}

View File

@ -4,6 +4,7 @@ namespace ss
{
class MFIMMsgConext;
class SS_IM_ForwardGuildCMMsg;
class SS_IM_ForwardGuildSMMsg;
}
class Guild;
@ -33,6 +34,7 @@ class GuildMgr : public a8::Singleton<GuildMgr>
int msgid,
const ::google::protobuf::Message& smmsg);
void _SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_ForwardGuildCMMsg& msg);
void _SS_IM_ForwardGuildSMMsg(f8::MsgHdr& hdr, const ss::SS_IM_ForwardGuildSMMsg& msg);
private:
void CreateAsyncTask(int socket_handle, long long guild_id, AsyncGuildTask* task);

View File

@ -97,6 +97,7 @@ void HandlerMgr::RegisterNetMsgHandlers()
RegisterNetMsgHandler(&wsmsghandler, &Player::_CMGroupRename);
RegisterNetMsgHandler(&immsghandler, &GuildMgr::_SS_IM_ForwardGuildCMMsg);
RegisterNetMsgHandler(&immsghandler, &GuildMgr::_SS_IM_ForwardGuildSMMsg);
RegisterNetMsgHandler(&wsmsghandler, &Player::_CMGuildInfo);
RegisterNetMsgHandler(&wsmsghandler, &Player::_CMGuildCreate);

View File

@ -1094,6 +1094,7 @@ void Player::FillIMMsgConext(ss::MFIMMsgConext* context)
{
FillMFUserInfo(context->mutable_user_info());
context->set_seqid(App::Instance()->NewSeqId());
context->set_socket_handle(socket_handle);
}
void Player::ForwardGroupCMMsg(f8::MsgHdr& hdr, long long hash_code)

View File

@ -194,7 +194,7 @@ void SyncHelper::SendIMConnMsg(int instance_id, int msgid, const ::google::proto
}
App::Instance()->AddSocketMsg
(
SF_IMServer,
SF_IMConn,
0,
0,
msgid,

View File

@ -6,6 +6,7 @@ message MFIMMsgConext
{
optional int64 seqid = 1;
optional cs.MFUserInfo user_info = 2;
optional int32 socket_handle = 3;
}
message MFIMServerInfo

@ -1 +1 @@
Subproject commit a1c591dd5f2bad2aba07134fa6b9c2415abff318
Subproject commit 579efb2289bc7391e68875fc58ada395ca1a6e2a