diff --git a/server/robotserver/app.cc b/server/robotserver/app.cc index 079ad9d3..9e9c047d 100644 --- a/server/robotserver/app.cc +++ b/server/robotserver/app.cc @@ -13,6 +13,7 @@ #include "httpproxy.h" #include "tracemgr.h" #include "iomgr.h" +#include "GGListener.h" #include "mt/MetaMgr.h" @@ -30,10 +31,12 @@ void App::Init() PlayerMgr::Instance()->Init(); HttpProxy::Instance()->Init(); IoMgr::Instance()->Init(); + GGListener::Instance()->Init(); } void App::UnInit() { + GGListener::Instance()->UnInit(); IoMgr::Instance()->UnInit(); PlayerMgr::Instance()->UnInit(); HttpProxy::Instance()->UnInit(); diff --git a/server/robotserver/player.cc b/server/robotserver/player.cc index b52dc0b4..c4b27fb8 100644 --- a/server/robotserver/player.cc +++ b/server/robotserver/player.cc @@ -4,8 +4,6 @@ #include #include -#include -#include #include #include @@ -78,59 +76,6 @@ void Player::Init(int idx, f8::UdpLog::Instance()->Warning("收到client非法数据包", {}); } }; - f8::CoMgr::Instance()->CreateCo - ( - [this] (f8::Coroutine* co) - { - CoGame(co); - }); -} - -void Player::CoGame(f8::Coroutine* co) -{ - { - web_socket_->Open(); - while (!net_connected_) { - co->CoYield(); - } - f8::UdpLog::Instance()->Info - ("WebSocketClient on_connect ok", {}); - } - { - cs::CMJoin msg; - msg.set_server_id(6); - msg.set_account_id(account_id_); - msg.set_session_id(session_id_); - msg.set_hero_id(30800); - SendMsg(msg); - } - { - while (!join_ok_) { - co->CoYield(); - } - f8::UdpLog::Instance()->Info - ("join ok", {}); - } - { - int seq_id = 0; - long long last_ping_tick = a8::XGetTickCount(); - long long last_cmmove_tick = a8::XGetTickCount(); - while (true) { - long long tick = a8::XGetTickCount(); - if (tick - last_ping_tick > 1000) { - cs::CMPing msg; - SendMsg(msg); - last_ping_tick = tick; - } - if (tick - last_cmmove_tick >= 100) { - cs::CMMove msg; - msg.set_seq(++seq_id); - SendMsg(msg); - last_cmmove_tick = tick; - } - co->CoYield(); - } - } } void Player::InternalSendMsg(int msgid, ::google::protobuf::Message& msg) diff --git a/server/robotserver/player.h b/server/robotserver/player.h index fe3819bc..8a3fda74 100644 --- a/server/robotserver/player.h +++ b/server/robotserver/player.h @@ -8,11 +8,6 @@ namespace a8 class WebSocketClient; } -namespace f8 -{ - class Coroutine; -} - class Player { public: @@ -66,7 +61,6 @@ public: void _SMNewBieEnd(f8::MsgHdr* hdr, const cs::SMNewBieEnd& msg); private: - void CoGame(f8::Coroutine* co); void InternalSendMsg(int msgid, ::google::protobuf::Message& msg); private: