1
This commit is contained in:
parent
8235f6016f
commit
9c711f3e62
@ -307,7 +307,7 @@ void Player::_CMFriendDeleteBlack(f8::MsgHdr& hdr, const cs::CMFriendDeleteBlack
|
|||||||
void Player::_CMSendChatMsg(f8::MsgHdr& hdr, const cs::CMSendChatMsg& msg)
|
void Player::_CMSendChatMsg(f8::MsgHdr& hdr, const cs::CMSendChatMsg& msg)
|
||||||
{
|
{
|
||||||
ss::SS_IM_SendChatMsg ss_msg;
|
ss::SS_IM_SendChatMsg ss_msg;
|
||||||
FillIMMsgConext(hdr, ss_msg.mutable_context());
|
FillIMMsgConext(ss_msg.mutable_context());
|
||||||
ss_msg.set_chat_channel(msg.chat_channel());
|
ss_msg.set_chat_channel(msg.chat_channel());
|
||||||
ss_msg.set_msg(msg.msg());
|
ss_msg.set_msg(msg.msg());
|
||||||
Friend* friend_data = GetFriendById(msg.target());
|
Friend* friend_data = GetFriendById(msg.target());
|
||||||
@ -319,7 +319,7 @@ void Player::_CMSendChatMsg(f8::MsgHdr& hdr, const cs::CMSendChatMsg& msg)
|
|||||||
void Player::_CMSendCustomMsg(f8::MsgHdr& hdr, const cs::CMSendCustomMsg& msg)
|
void Player::_CMSendCustomMsg(f8::MsgHdr& hdr, const cs::CMSendCustomMsg& msg)
|
||||||
{
|
{
|
||||||
ss::SS_IM_SendCustomMsg ss_msg;
|
ss::SS_IM_SendCustomMsg ss_msg;
|
||||||
FillIMMsgConext(hdr, ss_msg.mutable_context());
|
FillIMMsgConext(ss_msg.mutable_context());
|
||||||
ss_msg.set_msg(msg.msg());
|
ss_msg.set_msg(msg.msg());
|
||||||
ss_msg.set_param1(msg.param1());
|
ss_msg.set_param1(msg.param1());
|
||||||
ss_msg.set_param2(msg.param2());
|
ss_msg.set_param2(msg.param2());
|
||||||
@ -521,7 +521,7 @@ void Player::FillFriendList(::google::protobuf::RepeatedPtrField< ::cs::MFUserIn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::FillIMMsgConext(f8::MsgHdr& hdr, ss::MFIMMsgConext* context)
|
void Player::FillIMMsgConext(ss::MFIMMsgConext* context)
|
||||||
{
|
{
|
||||||
FillMFUserInfo(context->mutable_user_info());
|
FillMFUserInfo(context->mutable_user_info());
|
||||||
context->set_seqid(App::Instance()->NewSeqId());
|
context->set_seqid(App::Instance()->NewSeqId());
|
||||||
@ -530,7 +530,7 @@ void Player::FillIMMsgConext(f8::MsgHdr& hdr, ss::MFIMMsgConext* context)
|
|||||||
void Player::ForwardGroupCMMsg(f8::MsgHdr& hdr, long long hash_code)
|
void Player::ForwardGroupCMMsg(f8::MsgHdr& hdr, long long hash_code)
|
||||||
{
|
{
|
||||||
ss::SS_MS_ForwardGroupCMMsg msg;
|
ss::SS_MS_ForwardGroupCMMsg msg;
|
||||||
FillIMMsgConext(hdr, msg.mutable_context());
|
FillIMMsgConext(msg.mutable_context());
|
||||||
if (hdr.buflen > 0) {
|
if (hdr.buflen > 0) {
|
||||||
msg.mutable_payload()->assign(hdr.buf, hdr.buflen);
|
msg.mutable_payload()->assign(hdr.buf, hdr.buflen);
|
||||||
}
|
}
|
||||||
|
@ -97,12 +97,12 @@ class Player
|
|||||||
void NotifyOnline();
|
void NotifyOnline();
|
||||||
void NotifyOffline();
|
void NotifyOffline();
|
||||||
void NotifyUserInfoUpdate(Friend* friend_data);
|
void NotifyUserInfoUpdate(Friend* friend_data);
|
||||||
|
void FillIMMsgConext(ss::MFIMMsgConext* context);
|
||||||
|
|
||||||
const std::string AccountId();
|
const std::string AccountId();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void FillFriendList(::google::protobuf::RepeatedPtrField< ::cs::MFUserInfo >* friend_list);
|
void FillFriendList(::google::protobuf::RepeatedPtrField< ::cs::MFUserInfo >* friend_list);
|
||||||
void FillIMMsgConext(f8::MsgHdr& hdr, ss::MFIMMsgConext* context);
|
|
||||||
void FillMFUserInfo(cs::MFUserInfo* user_info);
|
void FillMFUserInfo(cs::MFUserInfo* user_info);
|
||||||
void ForwardGroupCMMsg(f8::MsgHdr& hdr, long long hash_code);
|
void ForwardGroupCMMsg(f8::MsgHdr& hdr, long long hash_code);
|
||||||
void SaveToDB(a8::XParams param, f8::AsyncDBOnOkFunc on_ok, f8::AsyncDBOnErrorFunc on_error);
|
void SaveToDB(a8::XParams param, f8::AsyncDBOnOkFunc on_ok, f8::AsyncDBOnErrorFunc on_error);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
|
|
||||||
#include <a8/openssl.h>
|
#include <a8/openssl.h>
|
||||||
|
#include <a8/timer.h>
|
||||||
|
|
||||||
#include "synchelper.h"
|
#include "synchelper.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
@ -22,16 +23,58 @@ void SyncHelper::UnInit()
|
|||||||
|
|
||||||
void SyncHelper::SyncNewFriend(Player* hum, const std::string& target_id)
|
void SyncHelper::SyncNewFriend(Player* hum, const std::string& target_id)
|
||||||
{
|
{
|
||||||
ss::SS_IM_FriendAgreeRequest notifymsg;
|
ss::SS_IM_FriendAgreeRequest* notifymsg = new ss::SS_IM_FriendAgreeRequest;
|
||||||
notifymsg.set_target_id(target_id);
|
hum->FillIMMsgConext(notifymsg->mutable_context());
|
||||||
BroadcastIMConnMsg(notifymsg);
|
notifymsg->set_target_id(target_id);
|
||||||
|
BroadcastIMConnMsg(*notifymsg);
|
||||||
|
pending_request_hash_[notifymsg->context().seqid()] =
|
||||||
|
a8::Timer::Instance()->AddDeadLineTimer
|
||||||
|
(
|
||||||
|
1000 * 10,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(notifymsg)
|
||||||
|
.SetParam1(notifymsg->context().seqid()),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
ss::SS_IM_FriendAgreeRequest* notifymsg =
|
||||||
|
(ss::SS_IM_FriendAgreeRequest*)param.sender.GetUserData();
|
||||||
|
},
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
ss::SS_IM_FriendAgreeRequest* notifymsg =
|
||||||
|
(ss::SS_IM_FriendAgreeRequest*)param.sender.GetUserData();
|
||||||
|
delete notifymsg;
|
||||||
|
SyncHelper::Instance()->RemovePendingRequest(param.param1);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
ss::SS_IM_FriendDeleteRequest* notifymsg = new ss::SS_IM_FriendDeleteRequest();
|
||||||
notifymsg.set_target_id(target_id);
|
hum->FillIMMsgConext(notifymsg->mutable_context());
|
||||||
BroadcastIMConnMsg(notifymsg);
|
notifymsg->set_target_id(target_id);
|
||||||
|
BroadcastIMConnMsg(*notifymsg);
|
||||||
|
pending_request_hash_[notifymsg->context().seqid()] =
|
||||||
|
a8::Timer::Instance()->AddDeadLineTimer
|
||||||
|
(
|
||||||
|
1000 * 10,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(notifymsg)
|
||||||
|
.SetParam1(notifymsg->context().seqid()),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
ss::SS_IM_FriendDeleteRequest* notifymsg =
|
||||||
|
(ss::SS_IM_FriendDeleteRequest*)param.sender.GetUserData();
|
||||||
|
},
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
ss::SS_IM_FriendDeleteRequest* notifymsg =
|
||||||
|
(ss::SS_IM_FriendDeleteRequest*)param.sender.GetUserData();
|
||||||
|
delete notifymsg;
|
||||||
|
SyncHelper::Instance()->RemovePendingRequest(param.param1);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SyncHelper::SyncUpdateFriend(Player* hum, const std::string& target_id)
|
void SyncHelper::SyncUpdateFriend(Player* hum, const std::string& target_id)
|
||||||
@ -72,10 +115,23 @@ void SyncHelper::BroadcastIMConnMsg(int msgid, ::google::protobuf::Message& msg)
|
|||||||
|
|
||||||
void SyncHelper::_SS_IM_FriendAgreeResponse(f8::MsgHdr& hdr, const ss::SS_IM_FriendAgreeResponse& msg)
|
void SyncHelper::_SS_IM_FriendAgreeResponse(f8::MsgHdr& hdr, const ss::SS_IM_FriendAgreeResponse& msg)
|
||||||
{
|
{
|
||||||
|
auto itr = pending_request_hash_.find(msg.context().seqid());
|
||||||
|
if (itr != pending_request_hash_.end()) {
|
||||||
|
a8::Timer::Instance()->DeleteTimer(itr->second);
|
||||||
|
RemovePendingRequest(msg.context().seqid());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SyncHelper::_SS_IM_FriendDeleteResponse(f8::MsgHdr& hdr, const ss::SS_IM_FriendDeleteResponse& msg)
|
void SyncHelper::_SS_IM_FriendDeleteResponse(f8::MsgHdr& hdr, const ss::SS_IM_FriendDeleteResponse& msg)
|
||||||
{
|
{
|
||||||
|
auto itr = pending_request_hash_.find(msg.context().seqid());
|
||||||
|
if (itr != pending_request_hash_.end()) {
|
||||||
|
a8::Timer::Instance()->DeleteTimer(itr->second);
|
||||||
|
RemovePendingRequest(msg.context().seqid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SyncHelper::RemovePendingRequest(long long seqid)
|
||||||
|
{
|
||||||
|
pending_request_hash_.erase(seqid);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ namespace ss
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Player;
|
class Player;
|
||||||
|
struct timer_list;
|
||||||
class SyncHelper : public a8::Singleton<SyncHelper>
|
class SyncHelper : public a8::Singleton<SyncHelper>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -27,6 +28,10 @@ class SyncHelper : public a8::Singleton<SyncHelper>
|
|||||||
void _SS_IM_FriendAgreeResponse(f8::MsgHdr& hdr, const ss::SS_IM_FriendAgreeResponse& msg);
|
void _SS_IM_FriendAgreeResponse(f8::MsgHdr& hdr, const ss::SS_IM_FriendAgreeResponse& msg);
|
||||||
void _SS_IM_FriendDeleteResponse(f8::MsgHdr& hdr, const ss::SS_IM_FriendDeleteResponse& msg);
|
void _SS_IM_FriendDeleteResponse(f8::MsgHdr& hdr, const ss::SS_IM_FriendDeleteResponse& msg);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void RemovePendingRequest(long long seqid);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void BroadcastIMConnMsg(T& msg)
|
void BroadcastIMConnMsg(T& msg)
|
||||||
@ -36,4 +41,6 @@ class SyncHelper : public a8::Singleton<SyncHelper>
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BroadcastIMConnMsg(int msgid, ::google::protobuf::Message& msg);
|
void BroadcastIMConnMsg(int msgid, ::google::protobuf::Message& msg);
|
||||||
|
|
||||||
|
std::map<long long, timer_list*> pending_request_hash_;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user