aozhiwei 2a218d6dd5 1
2020-06-13 22:41:57 +08:00

83 lines
2.9 KiB
C++

#pragma once
#include "cs_proto.pb.h"
#include "ss_proto.pb.h"
#include "WSListener.h"
struct timer_list;
class Player
{
public:
enum { HID = HID_Player };
public:
int socket_handle = 0;
unsigned int crc32_code = 0;
a8::TimerAttacher timer_attacher;
Friend data;
int today_invite_times = 0;
int last_invite_time = 0;
public:
void Init();
void UnInit();
void Deserialize(const ss::MFUserDB& friend_db);
void Serialize(ss::MFUserDB& friend_db);
template <typename T>
void SendMsg(T& msg)
{
WSListener::Instance()->SendToClient(socket_handle, 0, msg);
}
void _CMUpdateUserInfo(f8::MsgHdr& hdr, const cs::CMUpdateUserInfo& msg);
void _CMUpdateTempCustomData(f8::MsgHdr& hdr, const cs::CMUpdateTempCustomData& msg);
void _CMFriendList(f8::MsgHdr& hdr, const cs::CMFriendList& msg);
void _CMFriendApply(f8::MsgHdr& hdr, const cs::CMFriendApply& msg);
void _CMFriendApplyList(f8::MsgHdr& hdr, const cs::CMFriendApplyList& msg);
void _CMFriendAgree(f8::MsgHdr& hdr, const cs::CMFriendAgree& msg);
void _CMFriendIgnore(f8::MsgHdr& hdr, const cs::CMFriendIgnore& msg);
void _CMFriendDelete(f8::MsgHdr& hdr, const cs::CMFriendDelete& msg);
void _CMFriendBlackList(f8::MsgHdr& hdr, const cs::CMFriendBlackList& msg);
void _CMFriendAddBlack(f8::MsgHdr& hdr, const cs::CMFriendAddBlack& msg);
void _CMFriendDeleteBlack(f8::MsgHdr& hdr, const cs::CMFriendDeleteBlack& msg);
void _CMSendChatMsg(f8::MsgHdr& hdr, const cs::CMSendChatMsg& msg);
void _CMSendCustomMsg(f8::MsgHdr& hdr, const cs::CMSendCustomMsg& msg);
void _CMGroupCreate(f8::MsgHdr& hdr, const cs::CMGroupCreate& msg);
void _CMGroupJoin(f8::MsgHdr& hdr, const cs::CMGroupJoin& msg);
void _CMGroupAgree(f8::MsgHdr& hdr, const cs::CMGroupAgree& msg);
void _CMGroupKick(f8::MsgHdr& hdr, const cs::CMGroupKick& msg);
void _CMGroupQuit(f8::MsgHdr& hdr, const cs::CMGroupQuit& msg);
void _CMGroupDismiss(f8::MsgHdr& hdr, const cs::CMGroupDismiss& msg);
void _CMGroupRename(f8::MsgHdr& hdr, const cs::CMGroupRename& msg);
void ReLogin(f8::MsgHdr& hdr, const cs::CMLogin& msg);
void SyncLocToMasterServer();
void NotifyOnline();
void NotifyOffline();
void MarkDirty();
private:
void FillFriendList(::google::protobuf::RepeatedPtrField< ::cs::MFUserInfo >* friend_list);
void FillIMMsgConext(f8::MsgHdr& hdr, ss::MFIMMsgConext* conext);
void ForwardGroupCMMsg(f8::MsgHdr& hdr, long long hash_code);
void SaveToDB();
Friend* GetFriendById(const std::string& friend_id);
void FillApplyList(const cs::MFPaging& paging, cs::SMFriendApplyList& respmsg);
void OnDataVersion1Change();
void OnTempCustomDataChange();
private:
bool dirty_ = false;
timer_list* dirty_timer_ = nullptr;
long long last_apply_idx_ = 0;
std::map<std::string, Friend> friend_hash_;
std::map<long long, FriendApply*> apply_hash_;
std::list<FriendApply> apply_list_;
};