64 lines
2.0 KiB
C++
64 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include "cs_proto.pb.h"
|
|
|
|
struct ChatMsgRec
|
|
{
|
|
long long curr_id = 0;
|
|
long long last_id = 0;
|
|
std::list<cs::MFChatMsg*> msg_list;
|
|
|
|
~ChatMsgRec();
|
|
void Pop(size_t max_num);
|
|
void PopAndDelete(size_t max_num);
|
|
};
|
|
|
|
class Player;
|
|
struct ChatedUserRec;
|
|
class ChatMgr : public a8::Singleton<ChatMgr>
|
|
{
|
|
private:
|
|
ChatMgr() {};
|
|
friend class a8::Singleton<ChatMgr>;
|
|
|
|
public:
|
|
void Init();
|
|
void UnInit();
|
|
|
|
void FillSMUpdateChatRedPointNotify(Player* hum, cs::SMUpdateChatRedPointNotify& msg);
|
|
void FillSMUpdatePrivateChatRedPointNotify(Player* hum, cs::SMUpdatePrivateChatRedPointNotify& msg);
|
|
|
|
void ProcWorldChat(Player* hum, const cs::CMSendChatMsg& msg);
|
|
void ProcPrivateChat(Player* hum, const cs::CMSendChatMsg& msg);
|
|
void ProcGuildChat(Player* hum, const cs::CMSendChatMsg& msg);
|
|
void ProcTeamChat(Player* hum, const cs::CMSendChatMsg& msg);
|
|
void ProcBigHornChat(Player* hum, const cs::CMSendChatMsg& msg);
|
|
void ProcLoopMsgChat(Player* hum, const cs::CMSendChatMsg& msg);
|
|
|
|
void SyncWorldChatMsg(Player* hum);
|
|
void SyncPrivateChatMsg(Player* hum);
|
|
void SyncGuildChatMsg(Player* hum);
|
|
|
|
void OnPlayerOnline(Player* hum);
|
|
void OnPlayerOffline(Player* hum);
|
|
|
|
private:
|
|
ChatedUserRec* GetChatedUser(const std::string& account_id);
|
|
void AddChatedUser(const std::string& sender_id, const std::string& receiver_id,
|
|
cs::MFChatMsg* chat_msg, long long last_id);
|
|
void FillMFChatMsg(cs::MFChatMsg* msg, Player* sender, long long msg_uuid,
|
|
int chat_channel, int msg_type, const std::string& msg_body);
|
|
void RemoveChatedUser(const std::string& account_id);
|
|
|
|
private:
|
|
long long world_msg_id_ = 1000;
|
|
long long guild_msg_id_ = 1000;
|
|
long long temp_msg_id_ = 1000;
|
|
ChatMsgRec world_msgrec_;
|
|
std::map<long long, ChatMsgRec> guild_msgrec_;
|
|
std::map<std::string, ChatedUserRec*> private_chated_users_;
|
|
std::map<std::string, cs::MFChatMsg*> team_msg_hash_;
|
|
ChatMsgRec bighorn_msgrec_;
|
|
ChatMsgRec loop_msgrec_;
|
|
};
|