1
This commit is contained in:
parent
d6f90cd4cb
commit
dcd3c603f3
@ -292,6 +292,25 @@ void App::DispatchMsg()
|
||||
|
||||
void App::ProcessGameServerMsg(f8::MsgHdr& hdr)
|
||||
{
|
||||
f8::NetMsgHandler* handler = f8::GetNetMsgHandler(&HandlerMgr::Instance()->gsmsghandler,
|
||||
hdr.msgid);
|
||||
if (handler) {
|
||||
switch (handler->handlerid) {
|
||||
case HID_Player:
|
||||
{
|
||||
auto player = PlayerMgr::Instance()->GetPlayerBySocketHandle(hdr.socket_handle);
|
||||
if (player) {
|
||||
ProcessNetMsg(handler, player.get(), hdr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
abort();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void App::InitLog()
|
||||
|
@ -23,7 +23,7 @@ class HandlerMgr : public a8::Singleton<HandlerMgr>
|
||||
void Init();
|
||||
void UnInit();
|
||||
|
||||
f8::NetMsgHandlerObject ggmsghandler;
|
||||
f8::NetMsgHandlerObject gsmsghandler;
|
||||
|
||||
void RegisterGMMsgHandler(const std::string& msgname,
|
||||
void (*)(std::shared_ptr<f8::JsonHttpRequest>));
|
||||
|
@ -21,6 +21,9 @@ A8_DECLARE_ENUM(PlayerState_e,
|
||||
|
||||
class Player
|
||||
{
|
||||
public:
|
||||
enum { HID = HID_Player };
|
||||
|
||||
public:
|
||||
|
||||
void Update();
|
||||
|
@ -113,3 +113,15 @@ void PlayerMgr::CoCreatePlayer(f8::Coroutine* co,
|
||||
account_id_hash_[hum->GetAccountId()] = hum;
|
||||
socket_id_hash_[hum->GetSocketId()] = hum;
|
||||
}
|
||||
|
||||
std::shared_ptr<Player> PlayerMgr::GetPlayerByAccountId(const std::string& account_id)
|
||||
{
|
||||
auto itr = account_id_hash_.find(account_id);
|
||||
return itr != account_id_hash_.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<Player> PlayerMgr::GetPlayerBySocketHandle(int socket_handle)
|
||||
{
|
||||
auto itr = socket_id_hash_.find(socket_handle);
|
||||
return itr != socket_id_hash_.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ class PlayerMgr : public a8::Singleton<PlayerMgr>
|
||||
void Init();
|
||||
void UnInit();
|
||||
void Update();
|
||||
std::shared_ptr<Player> GetPlayerByAccountId(const std::string& account_id);
|
||||
std::shared_ptr<Player> GetPlayerBySocketHandle(int socket_handle);
|
||||
|
||||
private:
|
||||
void CoWebLogin(int idx, f8::Coroutine* co);
|
||||
|
Loading…
x
Reference in New Issue
Block a user