12 #include "../OSSupport/Network.h"
77 virtual void OnError(
int a_ErrorCode,
const AString & a_ErrorMsg)
override;
std::shared_ptr< cLuaUDPEndpoint > cLuaUDPEndpointPtr
std::shared_ptr< cUDPEndpoint > cUDPEndpointPtr
std::unique_ptr< cTableRef > cTableRefPtr
cLuaState::cTableRefPtr m_Callbacks
The Lua table that holds the callbacks to be invoked.
virtual void OnReceivedData(const char *a_Data, size_t a_Size, const AString &a_RemotePeer, UInt16 a_RemotePort) override
Called when there is an incoming datagram from a remote host.
virtual void OnError(int a_ErrorCode, const AString &a_ErrorMsg) override
Called when an error occurs on the endpoint.
cLuaUDPEndpointPtr m_Self
SharedPtr to self, so that the object can keep itself alive for as long as it needs (for Lua).
virtual ~cLuaUDPEndpoint() override
void Terminated(void)
Common code called when the endpoint is considered as terminated.
void Close(void)
Closes the UDP listener.
cUDPEndpointPtr m_Endpoint
The underlying network endpoint.
void EnableBroadcasts(void)
Enables outgoing broadcasts to be made using this endpoint.
bool IsOpen(void) const
Returns true if the endpoint is open for incoming data.
UInt16 GetPort(void) const
Returns the port on which endpoint is listening for incoming data.
void Release(void)
Called when Lua garbage-collects the object.
cLuaUDPEndpoint(cLuaState::cTableRefPtr &&a_Callbacks)
Creates a new instance of the endpoint, wrapping the callbacks that are in the specified table.
bool Open(UInt16 a_Port, cLuaUDPEndpointPtr a_Self)
Opens the endpoint so that it starts listening for incoming data on the specified port.
bool Send(const AString &a_Data, const AString &a_RemotePeer, UInt16 a_RemotePort)
Sends the data contained in the string to the specified remote peer.
Interface for the callbacks for events that can happen on the endpoint.