72 lines
1.4 KiB
C++
72 lines
1.4 KiB
C++
#include "precompile.h"
|
|
|
|
#include <a8/openssl.h>
|
|
|
|
#include "synchelper.h"
|
|
#include "player.h"
|
|
#include "playermgr.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::UnInit()
|
|
{
|
|
}
|
|
|
|
void SyncHelper::SyncNewFriend(Player* hum, const std::string& target_id)
|
|
{
|
|
ss::SS_IM_FriendAgreeRequest notifymsg;
|
|
notifymsg.set_target_id(target_id);
|
|
BroadcastIMConnMsg(notifymsg);
|
|
}
|
|
|
|
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::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);
|
|
}
|
|
}
|