1
This commit is contained in:
parent
39989d56da
commit
523420bb8f
@ -1,10 +1,12 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include <f8/coroutine.h>
|
||||
#include <a8/awaiter.h>
|
||||
#include <a8/promise.h>
|
||||
#include <a8/websocketclient.h>
|
||||
|
||||
#include <f8/coroutine.h>
|
||||
#include <f8/comgr.h>
|
||||
#include <f8/udplog.h>
|
||||
|
||||
#include "player.h"
|
||||
|
||||
@ -31,16 +33,44 @@ void Player::Init(int idx,
|
||||
|
||||
void Player::CoLogin(f8::Coroutine* co)
|
||||
{
|
||||
co->CoAwait
|
||||
([] (std::shared_ptr<a8::Awaiter> awaiter)
|
||||
{
|
||||
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 )
|
||||
{
|
||||
|
||||
});
|
||||
co->CoAwait
|
||||
([] (std::shared_ptr<a8::Awaiter> awaiter)
|
||||
{
|
||||
};
|
||||
web_socket_->Open();
|
||||
|
||||
});
|
||||
co->CoAwait
|
||||
(f8::CoMgr::Instance()->CreateCo
|
||||
(
|
||||
[this] (f8::Coroutine* co)
|
||||
{
|
||||
while (!net_connected_) {
|
||||
co->CoYield();
|
||||
}
|
||||
}
|
||||
).lock());
|
||||
f8::UdpLog::Instance()->Info
|
||||
("WebSocketClient on_connect ok", {});
|
||||
}
|
||||
|
||||
void Player::CoGame(f8::Coroutine* co)
|
||||
|
2
third_party/a8
vendored
2
third_party/a8
vendored
@ -1 +1 @@
|
||||
Subproject commit 888275763feaf537f01c190b23402325ebe1f9da
|
||||
Subproject commit fe229f0bb160d127e9d0264cb3e09132ed2fe528
|
2
third_party/f8
vendored
2
third_party/f8
vendored
@ -1 +1 @@
|
||||
Subproject commit 8eb3db11139b9a4d9b9056e2cd3412f7ebb48718
|
||||
Subproject commit 0b0158805fcdfaaf336f10a99f8f4f7421f28aa4
|
Loading…
x
Reference in New Issue
Block a user