67 lines
2.0 KiB
C++
67 lines
2.0 KiB
C++
#pragma once
|
|
|
|
namespace cs
|
|
{
|
|
class CMLogin;
|
|
}
|
|
|
|
namespace ss
|
|
{
|
|
class SS_WSP_SocketDisconnect;
|
|
class SS_MS_PushUserList;
|
|
class SS_IM_SendChatMsg;
|
|
}
|
|
|
|
class Player;
|
|
class PlayerMgr : public a8::Singleton<PlayerMgr>
|
|
{
|
|
public:
|
|
enum { HID = HID_PlayerMgr };
|
|
|
|
private:
|
|
PlayerMgr() {};
|
|
friend class a8::Singleton<PlayerMgr>;
|
|
|
|
public:
|
|
void Init();
|
|
void UnInit();
|
|
|
|
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_IM_SendChatMsg(f8::MsgHdr& hdr, const ss::SS_IM_SendChatMsg& msg);
|
|
|
|
void _CMLogin(f8::MsgHdr& hdr, const cs::CMLogin& msg);
|
|
|
|
Player* GetPlayerBySocket(int socket);
|
|
Player* GetPlayerByAccountId(const std::string& account_id);
|
|
void ReBindSocket(int socket_handle, Player* hum);
|
|
void OnWSProxyDisconnect(a8::XParams& param);
|
|
|
|
private:
|
|
int OnlineNum();
|
|
void OnClientDisconnect(a8::XParams& param);
|
|
void RemovePlayerBySocket(int socket_handle);
|
|
f8::MsgHdr* GetHdrBySocket(int socket_handle);
|
|
f8::MsgHdr* GetHdrByAccountId(const std::string& account_id);
|
|
void AsyncLogin1(const cs::CMLogin& msg);
|
|
void AsyncLogin2(const cs::CMLogin& msg);
|
|
void AsyncLoginOnOk(const std::string& account_id,
|
|
const std::string& nickname,
|
|
const std::string& avatar_url,
|
|
int sex,
|
|
long long group_id,
|
|
int data_version1);
|
|
void AsyncLoginOnError(const std::string& account_id,
|
|
int step,
|
|
int error_code,
|
|
const std::string& error_msg);
|
|
void OnClientSocketDisconnect(int socket_handle);
|
|
|
|
private:
|
|
std::map<int, Player*> socket_hash_;
|
|
std::map<std::string, Player*> accountid_hash_;
|
|
|
|
std::map<int, std::tuple<std::string, f8::MsgHdr*>> pending_socket_hash_;
|
|
std::map<std::string, f8::MsgHdr*> pending_account_hash_;
|
|
};
|