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