1
This commit is contained in:
parent
f5e300851e
commit
f910a16bfa
@ -16,4 +16,7 @@ class CacheMgr : public a8::Singleton<CacheMgr>
|
||||
void Init();
|
||||
void UnInit();
|
||||
|
||||
private:
|
||||
std::map<std::string, std::shared_ptr<UserInfo>> account_id_hash_;
|
||||
|
||||
};
|
||||
|
@ -9,7 +9,7 @@ namespace cs
|
||||
class CMSetCurrPrivateChatTarget;
|
||||
}
|
||||
|
||||
class Player
|
||||
class Player : public std::enable_shared_from_this<Player>
|
||||
{
|
||||
public:
|
||||
int socket_handle = 0;
|
||||
|
@ -29,7 +29,7 @@ int PlayerMgr::OnlineNum()
|
||||
return socket_hash_.size();
|
||||
}
|
||||
|
||||
Player* PlayerMgr::GetPlayerBySocket(int socket)
|
||||
std::shared_ptr<Player> PlayerMgr::GetPlayerBySocket(int socket)
|
||||
{
|
||||
auto itr = socket_hash_.find(socket);
|
||||
return itr != socket_hash_.end() ? itr->second : nullptr;
|
||||
@ -46,7 +46,7 @@ void PlayerMgr::OnClientDisconnect(int gg_socket)
|
||||
}
|
||||
}
|
||||
for (int socket_handle : socket_list) {
|
||||
Player* hum = GetPlayerBySocket(socket_handle);
|
||||
std::shared_ptr<Player> hum = GetPlayerBySocket(socket_handle);
|
||||
if (hum) {
|
||||
RemovePlayerBySocket(socket_handle);
|
||||
}
|
||||
@ -111,7 +111,7 @@ void PlayerMgr::DecAccountNum(const std::string& account_id)
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerMgr::ReBindSocket(Player* hum)
|
||||
void PlayerMgr::ReBindSocket(std::shared_ptr<Player> hum)
|
||||
{
|
||||
socket_hash_[hum->socket_handle] = hum;
|
||||
}
|
||||
|
@ -31,17 +31,16 @@ class PlayerMgr : public a8::Singleton<PlayerMgr>
|
||||
void _SS_Ping(f8::MsgHdr& hdr, const ss::SS_Ping& msg);
|
||||
|
||||
int OnlineNum();
|
||||
Player* GetPlayerBySocket(int socket);
|
||||
Player* CreatePlayerByCMLogin(Player* hum, long ip_saddr, int socket, const cs::CMLogin& msg);
|
||||
std::shared_ptr<Player> GetPlayerBySocket(int socket);
|
||||
void RemovePlayerBySocket(int socket_handle);
|
||||
size_t GetAccountNum() { return account_num_hash_.size(); }
|
||||
void IncAccountNum(const std::string& account_id);
|
||||
void DecAccountNum(const std::string& account_id);
|
||||
void ReBindSocket(Player* hum);
|
||||
void ReBindSocket(std::shared_ptr<Player> hum);
|
||||
|
||||
private:
|
||||
void OnClientDisconnect(int gg_socket);
|
||||
private:
|
||||
std::map<int, Player*> socket_hash_;
|
||||
std::map<int, std::shared_ptr<Player>> socket_hash_;
|
||||
std::map<std::string, int> account_num_hash_;
|
||||
};
|
||||
|
@ -1 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
struct UserInfo
|
||||
{
|
||||
std::string account_id;
|
||||
std::string name;
|
||||
};
|
||||
|
@ -13,8 +13,6 @@ enum CMMessageId_e
|
||||
_CMCloseChatNotify = 158;
|
||||
_CMSetCurrPrivateChatTarget = 159;
|
||||
|
||||
_CMGuildMsgBegin = 230;
|
||||
_CMGuildMsgEnd = 270;
|
||||
}
|
||||
|
||||
enum SMMessageId_e
|
||||
@ -24,9 +22,6 @@ enum SMMessageId_e
|
||||
|
||||
_SMLogin = 103;
|
||||
|
||||
_SMGuildMsgBegin = 230;
|
||||
_SMGuildMsgEnd = 270;
|
||||
|
||||
_SMUserStatusNotify = 501;
|
||||
_SMShowErrorMsg = 508;
|
||||
_SMCustomMsgNotify = 503;
|
||||
|
Loading…
x
Reference in New Issue
Block a user