1
This commit is contained in:
parent
2a218d6dd5
commit
558793991c
@ -5,6 +5,8 @@
|
|||||||
#include "jsondatamgr.h"
|
#include "jsondatamgr.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
|
#include "ss_proto.pb.h"
|
||||||
|
|
||||||
void IMConnMgr::Init()
|
void IMConnMgr::Init()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -44,3 +46,8 @@ IMConn* IMConnMgr::RecreateIMConn(const std::string& host, int port)
|
|||||||
conn->Open();
|
conn->Open();
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IMConnMgr::_SS_MS_IMServerList(f8::MsgHdr& hdr, const ss::SS_MS_IMServerList& msg)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,8 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
namespace ss
|
||||||
|
{
|
||||||
|
class MFIMMsgConext;
|
||||||
|
class SS_MS_LoadGroup;
|
||||||
|
class SS_MS_IMServerList;
|
||||||
|
}
|
||||||
|
|
||||||
class IMConn;
|
class IMConn;
|
||||||
class IMConnMgr : public a8::Singleton<IMConnMgr>
|
class IMConnMgr : public a8::Singleton<IMConnMgr>
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
enum { HID = HID_IMConnMgr };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IMConnMgr() {};
|
IMConnMgr() {};
|
||||||
friend class a8::Singleton<IMConnMgr>;
|
friend class a8::Singleton<IMConnMgr>;
|
||||||
@ -14,6 +24,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);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<std::string, IMConn*> key_hash_;
|
std::map<std::string, IMConn*> key_hash_;
|
||||||
|
@ -30,6 +30,7 @@ enum NetHandler_e
|
|||||||
HID_PlayerMgr,
|
HID_PlayerMgr,
|
||||||
HID_Player,
|
HID_Player,
|
||||||
HID_GroupMgr,
|
HID_GroupMgr,
|
||||||
|
HID_IMConnMgr,
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* const PROJ_NAME_FMT = "friend_imserver";
|
const char* const PROJ_NAME_FMT = "friend_imserver";
|
||||||
|
@ -123,7 +123,7 @@ void GroupMgr::_CMGroupJoin(const ss::MFIMMsgConext& context, const cs::CMGroupJ
|
|||||||
member->sex = context.sex();
|
member->sex = context.sex();
|
||||||
member->online = 1;
|
member->online = 1;
|
||||||
member->group_id = group->group_id;
|
member->group_id = group->group_id;
|
||||||
member->data_version1 = context.data_version1();
|
member->data_version1 = context.base_data_version();
|
||||||
group->AddMember(member);
|
group->AddMember(member);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "playermgr.h"
|
#include "playermgr.h"
|
||||||
#include "groupmgr.h"
|
#include "groupmgr.h"
|
||||||
|
#include "IMConnMgr.h"
|
||||||
|
|
||||||
#include "ss_proto.pb.h"
|
#include "ss_proto.pb.h"
|
||||||
#include "cs_proto.pb.h"
|
#include "cs_proto.pb.h"
|
||||||
@ -40,7 +41,10 @@ void HandlerMgr::RegisterNetMsgHandlers()
|
|||||||
RegisterNetMsgHandler(&mscmsghandler, &GroupMgr::_SS_MS_LoadGroup);
|
RegisterNetMsgHandler(&mscmsghandler, &GroupMgr::_SS_MS_LoadGroup);
|
||||||
RegisterNetMsgHandler(&mscmsghandler, &GroupMgr::_SS_MS_ForwardGroupCMMsg);
|
RegisterNetMsgHandler(&mscmsghandler, &GroupMgr::_SS_MS_ForwardGroupCMMsg);
|
||||||
|
|
||||||
|
RegisterNetMsgHandler(&mscmsghandler, &IMConnMgr::_SS_MS_IMServerList);
|
||||||
|
|
||||||
RegisterNetMsgHandler(&imcmsghandler, &PlayerMgr::_SS_IM_SendChatMsg);
|
RegisterNetMsgHandler(&imcmsghandler, &PlayerMgr::_SS_IM_SendChatMsg);
|
||||||
|
RegisterNetMsgHandler(&imcmsghandler, &PlayerMgr::_SS_IM_SendCustomMsg);
|
||||||
|
|
||||||
RegisterNetMsgHandler(&wsmsghandler, &WSListener::_SS_Ping);
|
RegisterNetMsgHandler(&wsmsghandler, &WSListener::_SS_Ping);
|
||||||
|
|
||||||
|
@ -258,12 +258,30 @@ 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;
|
||||||
|
FillIMMsgConext(hdr, ss_msg.mutable_context());
|
||||||
|
ss_msg.set_chat_channel(msg.chat_channel());
|
||||||
|
ss_msg.set_msg(msg.msg());
|
||||||
|
Friend* friend_data = GetFriendById(msg.target());
|
||||||
|
if (friend_data) {
|
||||||
|
SendSSMsg(*friend_data, ss_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;
|
||||||
|
FillIMMsgConext(hdr, ss_msg.mutable_context());
|
||||||
|
ss_msg.set_msg(msg.msg());
|
||||||
|
ss_msg.set_param1(msg.param1());
|
||||||
|
ss_msg.set_param2(msg.param2());
|
||||||
|
ss_msg.set_param3(msg.param3());
|
||||||
|
for (auto& target_id : msg.target_list()) {
|
||||||
|
Friend* friend_data = GetFriendById(target_id);
|
||||||
|
if (friend_data) {
|
||||||
|
SendSSMsg(*friend_data, ss_msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::_CMGroupCreate(f8::MsgHdr& hdr, const cs::CMGroupCreate& msg)
|
void Player::_CMGroupCreate(f8::MsgHdr& hdr, const cs::CMGroupCreate& msg)
|
||||||
@ -358,21 +376,6 @@ void Player::ReLogin(f8::MsgHdr& hdr, const cs::CMLogin& msg)
|
|||||||
SyncLocToMasterServer();
|
SyncLocToMasterServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SyncLocToMasterServer()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::NotifyOnline()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::NotifyOffline()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::FillFriendList(::google::protobuf::RepeatedPtrField< ::cs::MFUserInfo >* friend_list)
|
void Player::FillFriendList(::google::protobuf::RepeatedPtrField< ::cs::MFUserInfo >* friend_list)
|
||||||
{
|
{
|
||||||
for (auto& pair : friend_hash_) {
|
for (auto& pair : friend_hash_) {
|
||||||
@ -384,6 +387,7 @@ void Player::FillFriendList(::google::protobuf::RepeatedPtrField< ::cs::MFUserIn
|
|||||||
|
|
||||||
void Player::FillIMMsgConext(f8::MsgHdr& hdr, ss::MFIMMsgConext* conext)
|
void Player::FillIMMsgConext(f8::MsgHdr& hdr, ss::MFIMMsgConext* conext)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
conext->set_socket_handle(hdr.socket_handle);
|
conext->set_socket_handle(hdr.socket_handle);
|
||||||
conext->set_account_id(data.base_data.account_id);
|
conext->set_account_id(data.base_data.account_id);
|
||||||
conext->set_nickname(data.base_data.nickname);
|
conext->set_nickname(data.base_data.nickname);
|
||||||
@ -395,6 +399,7 @@ void Player::FillIMMsgConext(f8::MsgHdr& hdr, ss::MFIMMsgConext* conext)
|
|||||||
conext->set_online(online);
|
conext->set_online(online);
|
||||||
#endif
|
#endif
|
||||||
conext->set_msgid(hdr.msgid);
|
conext->set_msgid(hdr.msgid);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::ForwardGroupCMMsg(f8::MsgHdr& hdr, long long hash_code)
|
void Player::ForwardGroupCMMsg(f8::MsgHdr& hdr, long long hash_code)
|
||||||
@ -492,6 +497,21 @@ void Player::FillApplyList(const cs::MFPaging& paging, cs::SMFriendApplyList& re
|
|||||||
respmsg.mutable_paging()->set_total_page(ceil(i / paging.page_size()));
|
respmsg.mutable_paging()->set_total_page(ceil(i / paging.page_size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::SyncLocToMasterServer()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::NotifyOnline()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::NotifyOffline()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void Player::OnDataVersion1Change()
|
void Player::OnDataVersion1Change()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -501,3 +521,15 @@ void Player::OnTempCustomDataChange()
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::InternalSendSSMsg(const Friend& friend_data,
|
||||||
|
int msgid,
|
||||||
|
::google::protobuf::Message& msg)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string Player::AccountId()
|
||||||
|
{
|
||||||
|
return data.base_data.account_id;
|
||||||
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "ss_proto.pb.h"
|
#include "ss_proto.pb.h"
|
||||||
#include "WSListener.h"
|
#include "WSListener.h"
|
||||||
|
|
||||||
|
struct Friend;
|
||||||
struct timer_list;
|
struct timer_list;
|
||||||
class Player
|
class Player
|
||||||
{
|
{
|
||||||
@ -32,6 +33,39 @@ class Player
|
|||||||
WSListener::Instance()->SendToClient(socket_handle, 0, msg);
|
WSListener::Instance()->SendToClient(socket_handle, 0, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void SendSSMsg(const Friend& friend_data, T& msg)
|
||||||
|
{
|
||||||
|
static int msgid = f8::Net_GetMessageId(msg);
|
||||||
|
InternalSendSSMsg(friend_data, msgid, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void SendSSMsg(const std::vector<Friend*> friend_list, T& msg)
|
||||||
|
{
|
||||||
|
static int msgid = f8::Net_GetMessageId(msg);
|
||||||
|
for (auto& friend_data : friend_list) {
|
||||||
|
InternalSendSSMsg(*friend_data, msgid, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void BoradcastSSMsg(const T& msg)
|
||||||
|
{
|
||||||
|
static int msgid = f8::Net_GetMessageId(msg);
|
||||||
|
InternalSendSSMsg(data, msgid, msg);
|
||||||
|
BoradcastExcludeSSMsg(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void BoradcastExcludeSSMsg(const T& msg)
|
||||||
|
{
|
||||||
|
static int msgid = f8::Net_GetMessageId(msg);
|
||||||
|
for (auto& pair : friend_hash_) {
|
||||||
|
InternalSendSSMsg(pair.second, msgid, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _CMUpdateUserInfo(f8::MsgHdr& hdr, const cs::CMUpdateUserInfo& msg);
|
void _CMUpdateUserInfo(f8::MsgHdr& hdr, const cs::CMUpdateUserInfo& msg);
|
||||||
void _CMUpdateTempCustomData(f8::MsgHdr& hdr, const cs::CMUpdateTempCustomData& msg);
|
void _CMUpdateTempCustomData(f8::MsgHdr& hdr, const cs::CMUpdateTempCustomData& msg);
|
||||||
void _CMFriendList(f8::MsgHdr& hdr, const cs::CMFriendList& msg);
|
void _CMFriendList(f8::MsgHdr& hdr, const cs::CMFriendList& msg);
|
||||||
@ -56,10 +90,10 @@ class Player
|
|||||||
void _CMGroupRename(f8::MsgHdr& hdr, const cs::CMGroupRename& msg);
|
void _CMGroupRename(f8::MsgHdr& hdr, const cs::CMGroupRename& msg);
|
||||||
|
|
||||||
void ReLogin(f8::MsgHdr& hdr, const cs::CMLogin& msg);
|
void ReLogin(f8::MsgHdr& hdr, const cs::CMLogin& msg);
|
||||||
void SyncLocToMasterServer();
|
|
||||||
void NotifyOnline();
|
void NotifyOnline();
|
||||||
void NotifyOffline();
|
void NotifyOffline();
|
||||||
void MarkDirty();
|
|
||||||
|
const std::string AccountId();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void FillFriendList(::google::protobuf::RepeatedPtrField< ::cs::MFUserInfo >* friend_list);
|
void FillFriendList(::google::protobuf::RepeatedPtrField< ::cs::MFUserInfo >* friend_list);
|
||||||
@ -68,8 +102,13 @@ private:
|
|||||||
void SaveToDB();
|
void SaveToDB();
|
||||||
Friend* GetFriendById(const std::string& friend_id);
|
Friend* GetFriendById(const std::string& friend_id);
|
||||||
void FillApplyList(const cs::MFPaging& paging, cs::SMFriendApplyList& respmsg);
|
void FillApplyList(const cs::MFPaging& paging, cs::SMFriendApplyList& respmsg);
|
||||||
|
void SyncLocToMasterServer();
|
||||||
|
void MarkDirty();
|
||||||
void OnDataVersion1Change();
|
void OnDataVersion1Change();
|
||||||
void OnTempCustomDataChange();
|
void OnTempCustomDataChange();
|
||||||
|
void InternalSendSSMsg(const Friend& friend_data,
|
||||||
|
int msgid,
|
||||||
|
::google::protobuf::Message& msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool dirty_ = false;
|
bool dirty_ = false;
|
||||||
|
@ -35,6 +35,11 @@ void PlayerMgr::_SS_IM_SendChatMsg(f8::MsgHdr& hdr, const ss::SS_IM_SendChatMsg&
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerMgr::_SS_IM_SendCustomMsg(f8::MsgHdr& hdr, const ss::SS_IM_SendCustomMsg& 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());
|
||||||
|
@ -10,6 +10,7 @@ namespace ss
|
|||||||
class SS_WSP_SocketDisconnect;
|
class SS_WSP_SocketDisconnect;
|
||||||
class SS_MS_PushUserList;
|
class SS_MS_PushUserList;
|
||||||
class SS_IM_SendChatMsg;
|
class SS_IM_SendChatMsg;
|
||||||
|
class SS_IM_SendCustomMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Player;
|
class Player;
|
||||||
@ -29,6 +30,7 @@ class PlayerMgr : public a8::Singleton<PlayerMgr>
|
|||||||
void _SS_WSP_SocketDisconnect(f8::MsgHdr& hdr, const ss::SS_WSP_SocketDisconnect& msg);
|
void _SS_WSP_SocketDisconnect(f8::MsgHdr& hdr, const ss::SS_WSP_SocketDisconnect& msg);
|
||||||
void _SS_MS_PushUserList(f8::MsgHdr& hdr, const ss::SS_MS_PushUserList& msg);
|
void _SS_MS_PushUserList(f8::MsgHdr& hdr, const ss::SS_MS_PushUserList& msg);
|
||||||
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 _CMLogin(f8::MsgHdr& hdr, const cs::CMLogin& msg);
|
void _CMLogin(f8::MsgHdr& hdr, const cs::CMLogin& msg);
|
||||||
|
|
||||||
|
@ -2,15 +2,17 @@ package ss;
|
|||||||
|
|
||||||
message MFIMMsgConext
|
message MFIMMsgConext
|
||||||
{
|
{
|
||||||
optional int32 socket_handle = 1;
|
optional string account_id = 1; //账号id
|
||||||
optional string account_id = 2;
|
optional string nickname = 2; //昵称
|
||||||
optional string nickname = 3;
|
optional string avatar_url = 3; //头像
|
||||||
optional string avatar_url = 4;
|
optional int32 sex = 4; //性别 1:男 2:女 0:未知
|
||||||
optional int32 sex = 5;
|
optional int32 last_login_time = 5; //最后登录时间
|
||||||
optional int32 online = 6;
|
optional int32 group_id = 6; //群id
|
||||||
optional int32 msgid = 7;
|
|
||||||
optional int64 group_id = 8;
|
optional int64 user_value1 = 50; //用户字段1
|
||||||
optional int32 data_version1 = 9;
|
optional int64 user_value2 = 51; //用户字段2
|
||||||
|
optional int64 user_value3 = 52; //用户字段3
|
||||||
|
optional int64 base_data_version = 100; //数据版本号
|
||||||
}
|
}
|
||||||
|
|
||||||
message MFBaseUserDataDB
|
message MFBaseUserDataDB
|
||||||
@ -149,5 +151,23 @@ message SS_MS_PushUserList
|
|||||||
|
|
||||||
message SS_IM_SendChatMsg
|
message SS_IM_SendChatMsg
|
||||||
{
|
{
|
||||||
|
optional MFIMMsgConext context = 1;
|
||||||
|
optional int32 chat_channel = 2;
|
||||||
|
optional string msg = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SS_IM_SendCustomMsg
|
||||||
|
{
|
||||||
|
optional MFIMMsgConext context = 1;
|
||||||
|
optional string msg = 2;
|
||||||
|
optional int64 param1 = 3;
|
||||||
|
optional int64 param2 = 4;
|
||||||
|
optional int64 param3 = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SS_IM_IMServerList
|
||||||
|
{
|
||||||
|
}
|
||||||
|
message SS_MS_IMServerList
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user