1
This commit is contained in:
parent
362de597bb
commit
f9b0747b38
@ -30,7 +30,7 @@ class IMConn
|
|||||||
void SendMsg(T& msg)
|
void SendMsg(T& msg)
|
||||||
{
|
{
|
||||||
static int msgid = f8::Net_GetMessageId(msg);
|
static int msgid = f8::Net_GetMessageId(msg);
|
||||||
SendMsg(tcp_client_, msgid, msg);
|
SendMsg(msgid, msg);
|
||||||
}
|
}
|
||||||
void SendMsg(int msgid, ::google::protobuf::Message& msg)
|
void SendMsg(int msgid, ::google::protobuf::Message& msg)
|
||||||
{
|
{
|
||||||
|
@ -51,3 +51,12 @@ void IMConnMgr::_SS_MS_IMServerList(f8::MsgHdr& hdr, const ss::SS_MS_IMServerLis
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IMConnMgr::TraverseIMConn(std::function<bool (IMConn*)> func)
|
||||||
|
{
|
||||||
|
for (auto& pair : key_hash_) {
|
||||||
|
if (!func(pair.second)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -25,6 +25,7 @@ class IMConnMgr : public a8::Singleton<IMConnMgr>
|
|||||||
IMConn* GetConnByKey(const std::string& key);
|
IMConn* GetConnByKey(const std::string& key);
|
||||||
IMConn* RecreateIMConn(const std::string& host, int port);
|
IMConn* RecreateIMConn(const std::string& host, int port);
|
||||||
void _SS_MS_IMServerList(f8::MsgHdr& hdr, const ss::SS_MS_IMServerList& msg);
|
void _SS_MS_IMServerList(f8::MsgHdr& hdr, const ss::SS_MS_IMServerList& msg);
|
||||||
|
void TraverseIMConn(std::function<bool (IMConn*)> func);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<std::string, IMConn*> key_hash_;
|
std::map<std::string, IMConn*> key_hash_;
|
||||||
|
@ -35,3 +35,12 @@ MSConn* MSConnMgr::GetConnById(int instance_id)
|
|||||||
auto itr = id_hash_.find(instance_id);
|
auto itr = id_hash_.find(instance_id);
|
||||||
return itr != id_hash_.end() ? itr->second : nullptr;
|
return itr != id_hash_.end() ? itr->second : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MSConnMgr::TraverseMSConn(std::function<bool (MSConn*)> func)
|
||||||
|
{
|
||||||
|
for (auto& pair : id_hash_) {
|
||||||
|
if (!func(pair.second)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -23,6 +23,7 @@ class MSConnMgr : public a8::Singleton<MSConnMgr>
|
|||||||
}
|
}
|
||||||
conn->SendMsg(msg);
|
conn->SendMsg(msg);
|
||||||
}
|
}
|
||||||
|
void TraverseMSConn(std::function<bool (MSConn*)> func);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MSConn* GetConnById(int instance_id);
|
MSConn* GetConnById(int instance_id);
|
||||||
|
@ -45,6 +45,7 @@ void HandlerMgr::RegisterNetMsgHandlers()
|
|||||||
|
|
||||||
RegisterNetMsgHandler(&imcmsghandler, &PlayerMgr::_SS_IM_SendChatMsg);
|
RegisterNetMsgHandler(&imcmsghandler, &PlayerMgr::_SS_IM_SendChatMsg);
|
||||||
RegisterNetMsgHandler(&imcmsghandler, &PlayerMgr::_SS_IM_SendCustomMsg);
|
RegisterNetMsgHandler(&imcmsghandler, &PlayerMgr::_SS_IM_SendCustomMsg);
|
||||||
|
RegisterNetMsgHandler(&imcmsghandler, &PlayerMgr::_SS_IM_UpdateUserInfo);
|
||||||
|
|
||||||
RegisterNetMsgHandler(&wsmsghandler, &WSListener::_SS_Ping);
|
RegisterNetMsgHandler(&wsmsghandler, &WSListener::_SS_Ping);
|
||||||
|
|
||||||
|
@ -15,13 +15,16 @@
|
|||||||
|
|
||||||
#include "IMConn.h"
|
#include "IMConn.h"
|
||||||
#include "IMConnMgr.h"
|
#include "IMConnMgr.h"
|
||||||
|
#include "MSConn.h"
|
||||||
|
#include "MSConnMgr.h"
|
||||||
|
|
||||||
void Player::Init()
|
void Player::Init()
|
||||||
{
|
{
|
||||||
crc32_code = a8::openssl::Crc32(
|
crc32_code = a8::openssl::Crc32
|
||||||
(unsigned char*)data.base_data.account_id.data(),
|
(
|
||||||
data.base_data.account_id.size()
|
(unsigned char*)data.base_data.account_id.data(),
|
||||||
);
|
data.base_data.account_id.size()
|
||||||
|
);
|
||||||
SyncLocToMasterServer();
|
SyncLocToMasterServer();
|
||||||
NotifyOnline();
|
NotifyOnline();
|
||||||
}
|
}
|
||||||
@ -415,6 +418,11 @@ void Player::ForwardGroupCMMsg(f8::MsgHdr& hdr, long long hash_code)
|
|||||||
MSConnMgr::Instance()->SendMsg(msg, hash_code);
|
MSConnMgr::Instance()->SendMsg(msg, hash_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::FillMFUserInfo(cs::MFUserInfo* user_info)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void Player::MarkDirty()
|
void Player::MarkDirty()
|
||||||
{
|
{
|
||||||
if (!dirty_) {
|
if (!dirty_) {
|
||||||
@ -581,5 +589,22 @@ const std::string Player::AccountId()
|
|||||||
|
|
||||||
void Player::InternalUpdateUserInfo()
|
void Player::InternalUpdateUserInfo()
|
||||||
{
|
{
|
||||||
|
ss::SS_IM_UpdateUserInfo ss_msg;
|
||||||
|
FillMFUserInfo(ss_msg.mutable_user_info());
|
||||||
|
MSConnMgr::Instance()->TraverseMSConn
|
||||||
|
(
|
||||||
|
[&ss_msg] (MSConn* conn)
|
||||||
|
{
|
||||||
|
conn->SendMsg(ss_msg);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
IMConnMgr::Instance()->TraverseIMConn
|
||||||
|
(
|
||||||
|
[&ss_msg] (IMConn* conn)
|
||||||
|
{
|
||||||
|
conn->SendMsg(ss_msg);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,7 @@ class Player
|
|||||||
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* conext);
|
void FillIMMsgConext(f8::MsgHdr& hdr, ss::MFIMMsgConext* conext);
|
||||||
|
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();
|
void SaveToDB();
|
||||||
Friend* GetFriendById(const std::string& friend_id);
|
Friend* GetFriendById(const std::string& friend_id);
|
||||||
|
@ -40,6 +40,11 @@ void PlayerMgr::_SS_IM_SendCustomMsg(f8::MsgHdr& hdr, const ss::SS_IM_SendCustom
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerMgr::_SS_IM_UpdateUserInfo(f8::MsgHdr& hdr, const ss::SS_IM_UpdateUserInfo& msg)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void PlayerMgr::_CMLogin(f8::MsgHdr& hdr, const cs::CMLogin& msg)
|
void PlayerMgr::_CMLogin(f8::MsgHdr& hdr, const cs::CMLogin& msg)
|
||||||
{
|
{
|
||||||
Player* hum = GetPlayerByAccountId(msg.account_id());
|
Player* hum = GetPlayerByAccountId(msg.account_id());
|
||||||
|
@ -11,6 +11,7 @@ namespace ss
|
|||||||
class SS_MS_PushUserList;
|
class SS_MS_PushUserList;
|
||||||
class SS_IM_SendChatMsg;
|
class SS_IM_SendChatMsg;
|
||||||
class SS_IM_SendCustomMsg;
|
class SS_IM_SendCustomMsg;
|
||||||
|
class SS_IM_UpdateUserInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Player;
|
class Player;
|
||||||
@ -32,6 +33,8 @@ class PlayerMgr : public a8::Singleton<PlayerMgr>
|
|||||||
void _SS_IM_SendChatMsg(f8::MsgHdr& hdr, const ss::SS_IM_SendChatMsg& msg);
|
void _SS_IM_SendChatMsg(f8::MsgHdr& hdr, const ss::SS_IM_SendChatMsg& msg);
|
||||||
void _SS_IM_SendCustomMsg(f8::MsgHdr& hdr, const ss::SS_IM_SendCustomMsg& msg);
|
void _SS_IM_SendCustomMsg(f8::MsgHdr& hdr, const ss::SS_IM_SendCustomMsg& msg);
|
||||||
|
|
||||||
|
void _SS_IM_UpdateUserInfo(f8::MsgHdr& hdr, const ss::SS_IM_UpdateUserInfo& msg);
|
||||||
|
|
||||||
void _CMLogin(f8::MsgHdr& hdr, const cs::CMLogin& msg);
|
void _CMLogin(f8::MsgHdr& hdr, const cs::CMLogin& msg);
|
||||||
|
|
||||||
Player* GetPlayerBySocket(int socket);
|
Player* GetPlayerBySocket(int socket);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user