This commit is contained in:
azw 2023-08-19 15:03:23 +08:00
parent 7bf02217b7
commit d6f90cd4cb

View File

@ -9,6 +9,7 @@
#include <f8/udplog.h> #include <f8/udplog.h>
#include "player.h" #include "player.h"
#include "app.h"
#include "cs_proto.pb.h" #include "cs_proto.pb.h"
@ -26,7 +27,6 @@ void Player::Init(int idx,
account_id_ = account_id; account_id_ = account_id;
session_id_ = session_id; session_id_ = session_id;
web_socket_ = socket; web_socket_ = socket;
{
web_socket_->on_error = web_socket_->on_error =
[this] (a8::WebSocketClient*,int err_code) [this] (a8::WebSocketClient*,int err_code)
{ {
@ -47,11 +47,37 @@ void Player::Init(int idx,
("WebSocketClient on_disconnect", {}); ("WebSocketClient on_disconnect", {});
}; };
web_socket_->on_decode_userpacket = web_socket_->on_decode_userpacket =
[this] (char* buf, int& offset, unsigned int buflen) [this, socket_handle = GetSocketId()]
(char* buf, int& offset, unsigned int buflen)
{ {
bool warning = false;
}; while (buflen - offset >= sizeof(f8::PackHead)) {
f8::PackHead* p = (f8::PackHead*)&buf[offset];
if (p->magic_code == f8::MAGIC_CODE) {
if (buflen - offset < sizeof(f8::PackHead) + p->packlen) {
break;
} }
App::Instance()->AddSocketMsg
(SF_GameServer,
socket_handle,
//p->ip_saddr,
0,
p->msgid,
p->seqid,
&buf[offset + sizeof(f8::PackHead)],
p->packlen);
offset += sizeof(f8::PackHead) + p->packlen;
} else {
warning = true;
offset++;
continue;
}
}
if (warning) {
f8::UdpLog::Instance()->Warning("收到client非法数据包", {});
}
};
f8::CoMgr::Instance()->CreateCo f8::CoMgr::Instance()->CreateCo
( (
[this] (f8::Coroutine* co) [this] (f8::Coroutine* co)