diff --git a/server/robotserver/app.cc b/server/robotserver/app.cc index c02eddfd..33a435dc 100644 --- a/server/robotserver/app.cc +++ b/server/robotserver/app.cc @@ -268,9 +268,9 @@ void App::DispatchMsg() hdr.offset = 0; hdr.ip_saddr = pdelnode->ip_saddr; switch (pdelnode->sockfrom) { - case SF_GameGate: + case SF_GameServer: { - ProcessGameGateMsg(hdr); + ProcessGameServerMsg(hdr); } break; } @@ -290,7 +290,7 @@ void App::DispatchMsg() a8::tick_t end_tick = a8::XGetTickCount(); } -void App::ProcessGameGateMsg(f8::MsgHdr& hdr) +void App::ProcessGameServerMsg(f8::MsgHdr& hdr) { } diff --git a/server/robotserver/app.h b/server/robotserver/app.h index ebde2f22..363ceaa4 100644 --- a/server/robotserver/app.h +++ b/server/robotserver/app.h @@ -47,7 +47,7 @@ private: void DispatchMsg(); - void ProcessGameGateMsg(f8::MsgHdr& hdr); + void ProcessGameServerMsg(f8::MsgHdr& hdr); void InitLog(); void UnInitLog(); diff --git a/server/robotserver/constant.h b/server/robotserver/constant.h index 17709d8e..2639a6ee 100644 --- a/server/robotserver/constant.h +++ b/server/robotserver/constant.h @@ -2,7 +2,7 @@ enum SocketFrom_e { - SF_GameGate, + SF_GameServer, }; enum InnerMesssage_e diff --git a/server/robotserver/player.cc b/server/robotserver/player.cc index 800f182e..6225e47f 100644 --- a/server/robotserver/player.cc +++ b/server/robotserver/player.cc @@ -22,9 +22,36 @@ void Player::Init(int idx, const std::string& session_id, std::shared_ptr socket) { + socket_id_ = idx; account_id_ = account_id; session_id_ = session_id; web_socket_ = socket; + { + web_socket_->on_error = + [this] (a8::WebSocketClient*,int err_code) + { + f8::UdpLog::Instance()->Warning + ("WebSocketClient on_error %d", {err_code}); + }; + web_socket_->on_connect = + [this] (a8::WebSocketClient* ) + { + net_connected_ = true; + f8::UdpLog::Instance()->Info + ("WebSocketClient on_connect", {}); + }; + web_socket_->on_disconnect = + [this] (a8::WebSocketClient* ) + { + f8::UdpLog::Instance()->Warning + ("WebSocketClient on_disconnect", {}); + }; + web_socket_->on_decode_userpacket = + [this] (char* buf, int& offset, unsigned int buflen) + { + + }; + } f8::CoMgr::Instance()->CreateCo ( [this] (f8::Coroutine* co) @@ -35,31 +62,6 @@ void Player::Init(int idx, void Player::CoLogin(f8::Coroutine* co) { - web_socket_->on_error = - [this] (a8::WebSocketClient*,int err_code) - { - f8::UdpLog::Instance()->Warning - ("WebSocketClient on_error %d", {err_code}); - }; - web_socket_->on_connect = - [this] (a8::WebSocketClient* ) - { - net_connected_ = true; - f8::UdpLog::Instance()->Info - ("WebSocketClient on_connect", {}); - }; - web_socket_->on_disconnect = - [this] (a8::WebSocketClient* ) - { - f8::UdpLog::Instance()->Warning - ("WebSocketClient on_disconnect", {}); - }; - web_socket_->on_socketread = - [this] (a8::WebSocketClient*, char* buf,unsigned int buflen ) - { - - }; - { web_socket_->Open(); while (!net_connected_) { diff --git a/server/robotserver/playermgr.cc b/server/robotserver/playermgr.cc index 6488400c..d2fcbc46 100644 --- a/server/robotserver/playermgr.cc +++ b/server/robotserver/playermgr.cc @@ -16,7 +16,7 @@ void PlayerMgr::Init() { - for (int i = 0; i < 1; ++i) { + for (int i = 1; i <= 1; ++i) { f8::CoMgr::Instance()->CreateCo ( [this, i] (f8::Coroutine* co) @@ -111,4 +111,5 @@ void PlayerMgr::CoCreatePlayer(f8::Coroutine* co, auto hum = std::make_shared(); hum->Init(idx, account_id, session_id, socket); account_id_hash_[hum->GetAccountId()] = hum; + socket_id_hash_[hum->GetSocketId()] = hum; }