12 #include "../OSSupport/Network.h" 77 virtual void OnError(
int a_ErrorCode,
const AString & a_ErrorMsg)
override;
cLuaState::cTableRefPtr m_Callbacks
The Lua table that holds the callbacks to be invoked.
UInt16 GetPort(void) const
Returns the port on which endpoint is listening for incoming data.
std::unique_ptr< cTableRef > cTableRefPtr
bool IsOpen(void) const
Returns true if the endpoint is open for incoming data.
cLuaUDPEndpoint(cLuaState::cTableRefPtr &&a_Callbacks)
Creates a new instance of the endpoint, wrapping the callbacks that are in the specified table...
std::shared_ptr< cUDPEndpoint > cUDPEndpointPtr
Interface for the callbacks for events that can happen on the endpoint.
cUDPEndpointPtr m_Endpoint
The underlying network endpoint.
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.
std::shared_ptr< cLuaUDPEndpoint > cLuaUDPEndpointPtr
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 Close(void)
Closes the UDP listener.
void Release(void)
Called when Lua garbage-collects the object.
void EnableBroadcasts(void)
Enables outgoing broadcasts to be made using this endpoint.
void Terminated(void)
Common code called when the endpoint is considered as terminated.
virtual void OnError(int a_ErrorCode, const AString &a_ErrorMsg) override
Called when an error occurs on the endpoint.
bool Open(UInt16 a_Port, cLuaUDPEndpointPtr a_Self)
Opens the endpoint so that it starts listening for incoming data on the specified port...
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.