diff --git a/server/robotserver/player.cc b/server/robotserver/player.cc index 6649c536..00e7b40b 100644 --- a/server/robotserver/player.cc +++ b/server/robotserver/player.cc @@ -1,9 +1,33 @@ #include "precompile.h" #include +#include +#include + +#include #include "player.h" +class ConnectedPromise : public a8::Promise +{ +protected: + + virtual void DoAwait() override + { + } + +}; + +class JoinSuccessPromise : public a8::Promise +{ +protected: + + virtual void DoAwait() override + { + } + +}; + void Player::Update() { @@ -17,26 +41,21 @@ void Player::Init(int idx, account_id_ = account_id; session_id_ = session_id; web_socket_ = socket; -} - -void Player::CoNet(f8::Coroutine* co) -{ - #if 0 - co->Await(CoLogin); - co->Await(CoGame); - #endif + f8::CoMgr::Instance()->CreateCo + ( + [this] (f8::Coroutine* co) + { + CoLogin(co); + }); } void Player::CoLogin(f8::Coroutine* co) { - while (NetConnected()) { - - } + auto a = struct{}{}; + co->CoAwait(std::make_shared()); + co->CoAwait(std::make_shared()); } void Player::CoGame(f8::Coroutine* co) { - while (NetConnected()) { - - } } diff --git a/server/robotserver/player.h b/server/robotserver/player.h index 253b3da0..168893f5 100644 --- a/server/robotserver/player.h +++ b/server/robotserver/player.h @@ -34,10 +34,9 @@ public: int GetSocketId() { return socket_id_; } bool NetConnected() { return net_connected_; } const std::string& GetAccountId() { return account_id_; } + auto GetWebSocket() { return web_socket_; } private: - - void CoNet(f8::Coroutine* co); void CoLogin(f8::Coroutine* co); void CoGame(f8::Coroutine* co); diff --git a/server/robotserver/playermgr.cc b/server/robotserver/playermgr.cc index 5c60284e..6488400c 100644 --- a/server/robotserver/playermgr.cc +++ b/server/robotserver/playermgr.cc @@ -111,5 +111,4 @@ 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->Open(); } diff --git a/third_party/a8 b/third_party/a8 index 91b5f74b..0d5c381b 160000 --- a/third_party/a8 +++ b/third_party/a8 @@ -1 +1 @@ -Subproject commit 91b5f74b3a08a51674e825a499beba668b5d23be +Subproject commit 0d5c381b38618310d7b438a03c8942b14c0e0725 diff --git a/third_party/f8 b/third_party/f8 index 1a93316b..4384bc7a 160000 --- a/third_party/f8 +++ b/third_party/f8 @@ -1 +1 @@ -Subproject commit 1a93316b3852e72c999331172e293083bb059fdb +Subproject commit 4384bc7ac05ef6bad5e1dfe94b7d4211b81930c0