This commit is contained in:
aozhiwei 2023-04-23 19:14:21 +08:00
parent d0c0cabdca
commit 32076b1c5c
2 changed files with 4 additions and 5 deletions

View File

@ -6,6 +6,7 @@
#include <f8/udplog.h>
#include "kcpsession.h"
#include "longsessionmgr.h"
#include "app.h"
static const int DEFAULT_MAX_RECV_BUFFERSIZE = 1024 * 64;
@ -17,9 +18,7 @@ static int UdpOutput(const char *buf, int len, ikcpcb *kcp, void *user)
pkt->buf = buf;
pkt->buf_len = len;
pkt->remote_addr = session->GetAddr();
#if 0
session->GetUdpListener()->SendUdpPacket(pkt);
#endif
LongSessionMgr::Instance()->GetUdpListener()->SendUdpPacket(pkt);
return 0;
}
@ -70,7 +69,6 @@ void KcpSession::OnRecvPacket(a8::UdpPacket* pkt)
ikcp_input(kcp_, pkt->buf, pkt->buf_len);
}
void KcpSession::UpdateInput()
{
char buf[DEFAULT_MAX_RECV_BUFFERSIZE];
@ -110,6 +108,6 @@ void KcpSession::DecodeUserPacket(char* buf, int& offset, unsigned int buflen)
}
if (warning) {
f8::UdpLog::Instance()->Warning("收到client非法数据包", {});
f8::UdpLog::Instance()->Warning("收到kcp client非法数据包", {});
}
}

View File

@ -29,6 +29,7 @@ class LongSessionMgr : public a8::Singleton<LongSessionMgr>
void _SS_CMKcpHandshake(f8::MsgHdr& hdr, const ss::SS_CMKcpHandshake& msg);
void ProcUdpPacket(a8::UdpPacket* pkt);
std::shared_ptr<LongSession> GetSession(int socket_handle);
std::shared_ptr<a8::UdpListener> GetUdpListener() { return udp_listener_; }
private:
std::shared_ptr<a8::UdpListener> udp_listener_;