This commit is contained in:
azw 2023-08-19 14:59:08 +08:00
parent 65829307d6
commit 7bf02217b7
5 changed files with 34 additions and 31 deletions

View File

@ -268,9 +268,9 @@ void App::DispatchMsg()
hdr.offset = 0; hdr.offset = 0;
hdr.ip_saddr = pdelnode->ip_saddr; hdr.ip_saddr = pdelnode->ip_saddr;
switch (pdelnode->sockfrom) { switch (pdelnode->sockfrom) {
case SF_GameGate: case SF_GameServer:
{ {
ProcessGameGateMsg(hdr); ProcessGameServerMsg(hdr);
} }
break; break;
} }
@ -290,7 +290,7 @@ void App::DispatchMsg()
a8::tick_t end_tick = a8::XGetTickCount(); a8::tick_t end_tick = a8::XGetTickCount();
} }
void App::ProcessGameGateMsg(f8::MsgHdr& hdr) void App::ProcessGameServerMsg(f8::MsgHdr& hdr)
{ {
} }

View File

@ -47,7 +47,7 @@ private:
void DispatchMsg(); void DispatchMsg();
void ProcessGameGateMsg(f8::MsgHdr& hdr); void ProcessGameServerMsg(f8::MsgHdr& hdr);
void InitLog(); void InitLog();
void UnInitLog(); void UnInitLog();

View File

@ -2,7 +2,7 @@
enum SocketFrom_e enum SocketFrom_e
{ {
SF_GameGate, SF_GameServer,
}; };
enum InnerMesssage_e enum InnerMesssage_e

View File

@ -22,18 +22,10 @@ void Player::Init(int idx,
const std::string& session_id, const std::string& session_id,
std::shared_ptr<a8::WebSocketClient> socket) std::shared_ptr<a8::WebSocketClient> socket)
{ {
socket_id_ = idx;
account_id_ = account_id; account_id_ = account_id;
session_id_ = session_id; session_id_ = session_id;
web_socket_ = socket; web_socket_ = socket;
f8::CoMgr::Instance()->CreateCo
(
[this] (f8::Coroutine* co)
{
CoLogin(co);
});
}
void Player::CoLogin(f8::Coroutine* co)
{ {
web_socket_->on_error = web_socket_->on_error =
[this] (a8::WebSocketClient*,int err_code) [this] (a8::WebSocketClient*,int err_code)
@ -54,12 +46,22 @@ void Player::CoLogin(f8::Coroutine* co)
f8::UdpLog::Instance()->Warning f8::UdpLog::Instance()->Warning
("WebSocketClient on_disconnect", {}); ("WebSocketClient on_disconnect", {});
}; };
web_socket_->on_socketread = web_socket_->on_decode_userpacket =
[this] (a8::WebSocketClient*, char* buf,unsigned int buflen ) [this] (char* buf, int& offset, unsigned int buflen)
{ {
}; };
}
f8::CoMgr::Instance()->CreateCo
(
[this] (f8::Coroutine* co)
{
CoLogin(co);
});
}
void Player::CoLogin(f8::Coroutine* co)
{
{ {
web_socket_->Open(); web_socket_->Open();
while (!net_connected_) { while (!net_connected_) {

View File

@ -16,7 +16,7 @@
void PlayerMgr::Init() void PlayerMgr::Init()
{ {
for (int i = 0; i < 1; ++i) { for (int i = 1; i <= 1; ++i) {
f8::CoMgr::Instance()->CreateCo f8::CoMgr::Instance()->CreateCo
( (
[this, i] (f8::Coroutine* co) [this, i] (f8::Coroutine* co)
@ -111,4 +111,5 @@ void PlayerMgr::CoCreatePlayer(f8::Coroutine* co,
auto hum = std::make_shared<Player>(); auto hum = std::make_shared<Player>();
hum->Init(idx, account_id, session_id, socket); hum->Init(idx, account_id, session_id, socket);
account_id_hash_[hum->GetAccountId()] = hum; account_id_hash_[hum->GetAccountId()] = hum;
socket_id_hash_[hum->GetSocketId()] = hum;
} }