This commit is contained in:
azw 2023-04-22 08:59:54 +00:00
parent ac34ca2d3b
commit 736500c141
2 changed files with 58 additions and 0 deletions

31
a8/udpsession.cc Normal file
View File

@ -0,0 +1,31 @@
#include <a8/a8.h>
#include <a8/udpsession.h>
static const int DEFAULT_MAX_PACKET_LEN = 1024 * 10;
static const int DEFAULT_MAX_RECV_BUFFERSIZE = 1024 * 64;
namespace a8
{
UdpSession::UdpSession()
{
max_packet_len_ = DEFAULT_MAX_PACKET_LEN;
}
UdpSession::~UdpSession()
{
}
void UdpSession::Update()
{
}
void UdpSession::SetMaxPacketLen(int max_packet_len)
{
max_packet_len_ = std::max(max_packet_len, DEFAULT_MAX_PACKET_LEN);
}
}

27
a8/udpsession.h Normal file
View File

@ -0,0 +1,27 @@
#pragma once
namespace a8
{
class UdpListener;
class UdpSession
{
public:
UdpSession();
~UdpSession();
void Update();
void SetMaxPacketLen(int max_packet_len);
private:
a8::UdpListener* listener_ = nullptr;
long long remote_key_ = 0;
int socket_handle_ = 0;
sockaddr_in remote_addr_ = {};
char *recv_buff_ = nullptr;
int recv_bufflen_ = 0;
int max_packet_len_ = 0;
};
}