1
This commit is contained in:
parent
08ad1ade1c
commit
a20f329c6d
@ -1,9 +1,33 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include <f8/coroutine.h>
|
||||
#include <a8/awaiter.h>
|
||||
#include <a8/promise.h>
|
||||
|
||||
#include <f8/comgr.h>
|
||||
|
||||
#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<ConnectedPromise>());
|
||||
co->CoAwait(std::make_shared<JoinSuccessPromise>());
|
||||
}
|
||||
|
||||
void Player::CoGame(f8::Coroutine* co)
|
||||
{
|
||||
while (NetConnected()) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -111,5 +111,4 @@ void PlayerMgr::CoCreatePlayer(f8::Coroutine* co,
|
||||
auto hum = std::make_shared<Player>();
|
||||
hum->Init(idx, account_id, session_id, socket);
|
||||
account_id_hash_[hum->GetAccountId()] = hum;
|
||||
socket->Open();
|
||||
}
|
||||
|
2
third_party/a8
vendored
2
third_party/a8
vendored
@ -1 +1 @@
|
||||
Subproject commit 91b5f74b3a08a51674e825a499beba668b5d23be
|
||||
Subproject commit 0d5c381b38618310d7b438a03c8942b14c0e0725
|
2
third_party/f8
vendored
2
third_party/f8
vendored
@ -1 +1 @@
|
||||
Subproject commit 1a93316b3852e72c999331172e293083bb059fdb
|
||||
Subproject commit 4384bc7ac05ef6bad5e1dfe94b7d4211b81930c0
|
Loading…
x
Reference in New Issue
Block a user