1
This commit is contained in:
parent
7bf02217b7
commit
d6f90cd4cb
@ -9,6 +9,7 @@
|
||||
#include <f8/udplog.h>
|
||||
|
||||
#include "player.h"
|
||||
#include "app.h"
|
||||
|
||||
#include "cs_proto.pb.h"
|
||||
|
||||
@ -26,32 +27,57 @@ void Player::Init(int idx,
|
||||
account_id_ = account_id;
|
||||
session_id_ = session_id;
|
||||
web_socket_ = socket;
|
||||
{
|
||||
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_decode_userpacket =
|
||||
[this] (char* buf, int& offset, unsigned int buflen)
|
||||
{
|
||||
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_decode_userpacket =
|
||||
[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
|
||||
(
|
||||
[this] (f8::Coroutine* co)
|
||||
|
Loading…
x
Reference in New Issue
Block a user