This commit is contained in:
azw 2023-04-15 01:57:39 +00:00
parent 50341c6846
commit dd650c0bca
2 changed files with 21 additions and 6 deletions

View File

@ -107,7 +107,9 @@ namespace a8
(struct sockaddr*)&destAddr,
(socklen_t*)&addrLen);
if(ret > 0) {
#if 0
master->OnSocketRead(recv_buf, ret);
#endif
}
}
}
@ -126,10 +128,6 @@ namespace a8
impl_ = nullptr;
}
void UdpListener::OnSocketRead(char*, unsigned int)
{
}
void UdpListener::Open()
{
if (!IsActive()) {
@ -149,4 +147,14 @@ namespace a8
return impl_->IsActive();
}
void UdpListener::SendUdpPacket(UdpPacket* pkt)
{
}
void UdpListener::OnRecvUdpPacket(UdpPacket* pkt)
{
}
}

View File

@ -2,6 +2,12 @@
namespace a8
{
struct UdpPacket
{
char* buf = nullptr;
int buf_len = 0;
sockaddr_in remote_addr;
};
struct UdpListenerImpl;
class UdpListener
@ -15,10 +21,11 @@ namespace a8
UdpListener();
~UdpListener();
virtual void OnSocketRead(char*, unsigned int);
void Open();
void Close();
bool IsActive();
virtual void SendUdpPacket(UdpPacket* pkt);
virtual void OnRecvUdpPacket(UdpPacket* pkt);
private:
a8::UdpListenerImpl* impl_ = nullptr;