1
This commit is contained in:
parent
69e366b9b0
commit
a3c78fa43a
@ -34,6 +34,13 @@ class MSConn
|
|||||||
f8::DumpMsgToLog(msg, "<<<<<<<MSC ");
|
f8::DumpMsgToLog(msg, "<<<<<<<MSC ");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
void SendMsg(int msgid, ::google::protobuf::Message& msg)
|
||||||
|
{
|
||||||
|
f8::Net_SendMsg(tcp_client_, 0, msgid, msg);
|
||||||
|
#ifdef DEBUG
|
||||||
|
f8::DumpMsgToLog(msg, "<<<<<<<IMC ");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void OnConnectSync();
|
void OnConnectSync();
|
||||||
void OnDisconnectSync();
|
void OnDisconnectSync();
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "playermgr.h"
|
#include "playermgr.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
#include "IMConn.h"
|
||||||
|
#include "IMConnMgr.h"
|
||||||
|
|
||||||
|
#include "cs_proto.pb.h"
|
||||||
|
#include "ss_proto.pb.h"
|
||||||
|
|
||||||
void SyncHelper::Init()
|
void SyncHelper::Init()
|
||||||
{
|
{
|
||||||
@ -17,18 +22,50 @@ void SyncHelper::UnInit()
|
|||||||
|
|
||||||
void SyncHelper::SyncNewFriend(Player* hum, const std::string& target_id)
|
void SyncHelper::SyncNewFriend(Player* hum, const std::string& target_id)
|
||||||
{
|
{
|
||||||
Player* target = PlayerMgr::Instance()->GetPlayerByAccountId(target_id);
|
ss::SS_IM_FriendAgreeRequest notifymsg;
|
||||||
if (target) {
|
notifymsg.set_target_id(target_id);
|
||||||
|
BroadcastIMConnMsg(notifymsg);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SyncHelper::SyncDeleteFriend(Player* hum, const std::string& target_id)
|
void SyncHelper::SyncDeleteFriend(Player* hum, const std::string& target_id)
|
||||||
{
|
{
|
||||||
|
ss::SS_IM_FriendDeleteRequest notifymsg;
|
||||||
|
notifymsg.set_target_id(target_id);
|
||||||
|
BroadcastIMConnMsg(notifymsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SyncHelper::SyncUpdateFriend(Player* hum, const std::string& target_id)
|
void SyncHelper::SyncUpdateFriend(Player* hum, const std::string& target_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SyncHelper::BroadcastIMConnMsg(int msgid, ::google::protobuf::Message& msg)
|
||||||
|
{
|
||||||
|
IMConnMgr::Instance()->TraverseIMConn
|
||||||
|
(
|
||||||
|
[msgid, &msg] (IMConn* conn)
|
||||||
|
{
|
||||||
|
conn->SendMsg(msgid, msg);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -14,4 +14,14 @@ class SyncHelper : public a8::Singleton<SyncHelper>
|
|||||||
void SyncNewFriend(Player* hum, const std::string& target_id);
|
void SyncNewFriend(Player* hum, const std::string& target_id);
|
||||||
void SyncDeleteFriend(Player* hum, const std::string& target_id);
|
void SyncDeleteFriend(Player* hum, const std::string& target_id);
|
||||||
void SyncUpdateFriend(Player* hum, const std::string& target_id);
|
void SyncUpdateFriend(Player* hum, const std::string& target_id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
template <typename T>
|
||||||
|
void BroadcastIMConnMsg(T& msg)
|
||||||
|
{
|
||||||
|
static int msgid = f8::Net_GetMessageId(msg);
|
||||||
|
BroadcastIMConnMsg(msgid, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BroadcastIMConnMsg(int msgid, ::google::protobuf::Message& msg);
|
||||||
};
|
};
|
||||||
|
@ -30,4 +30,8 @@ enum SSMessageId_e
|
|||||||
_SS_IM_IMServerList = 1013;
|
_SS_IM_IMServerList = 1013;
|
||||||
_SS_MS_IMServerList = 1014;
|
_SS_MS_IMServerList = 1014;
|
||||||
_SS_IM_UpdateUserInfo = 1015;
|
_SS_IM_UpdateUserInfo = 1015;
|
||||||
|
_SS_IM_FriendAgreeRequest = 1016;
|
||||||
|
_SS_IM_FriendAgreeResponse = 1017;
|
||||||
|
_SS_IM_FriendDeleteRequest = 1018;
|
||||||
|
_SS_IM_FriendDeleteResponse = 1019;
|
||||||
}
|
}
|
||||||
|
@ -208,3 +208,15 @@ message SS_IM_FriendAgreeResponse
|
|||||||
optional MFIMMsgConext context = 1;
|
optional MFIMMsgConext context = 1;
|
||||||
optional string target_id = 3;
|
optional string target_id = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message SS_IM_FriendDeleteRequest
|
||||||
|
{
|
||||||
|
optional MFIMMsgConext context = 1;
|
||||||
|
optional string target_id = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SS_IM_FriendDeleteResponse
|
||||||
|
{
|
||||||
|
optional MFIMMsgConext context = 1;
|
||||||
|
optional string target_id = 3;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user