1
This commit is contained in:
parent
ac34ca2d3b
commit
736500c141
31
a8/udpsession.cc
Normal file
31
a8/udpsession.cc
Normal 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
27
a8/udpsession.h
Normal 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;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user