Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <LuaUDPEndpoint.h>
Public Member Functions | |
void | Close (void) |
Closes the UDP listener. More... | |
cLuaUDPEndpoint (cLuaState::cTableRefPtr &&a_Callbacks) | |
Creates a new instance of the endpoint, wrapping the callbacks that are in the specified table. More... | |
void | EnableBroadcasts (void) |
Enables outgoing broadcasts to be made using this endpoint. More... | |
UInt16 | GetPort (void) const |
Returns the port on which endpoint is listening for incoming data. More... | |
bool | IsOpen (void) const |
Returns true if the endpoint is open for incoming data. More... | |
bool | Open (UInt16 a_Port, cLuaUDPEndpointPtr a_Self) |
Opens the endpoint so that it starts listening for incoming data on the specified port. More... | |
void | Release (void) |
Called when Lua garbage-collects the object. More... | |
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. More... | |
virtual | ~cLuaUDPEndpoint () override |
Public Member Functions inherited from cUDPEndpoint::cCallbacks | |
virtual | ~cCallbacks () |
Protected Member Functions | |
virtual void | OnError (int a_ErrorCode, const AString &a_ErrorMsg) override |
Called when an error occurs on the endpoint. More... | |
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. More... | |
void | Terminated (void) |
Common code called when the endpoint is considered as terminated. More... | |
Protected Attributes | |
cLuaState::cTableRefPtr | m_Callbacks |
The Lua table that holds the callbacks to be invoked. More... | |
cUDPEndpointPtr | m_Endpoint |
The underlying network endpoint. More... | |
cLuaUDPEndpointPtr | m_Self |
SharedPtr to self, so that the object can keep itself alive for as long as it needs (for Lua). More... | |
Definition at line 27 of file LuaUDPEndpoint.h.
cLuaUDPEndpoint::cLuaUDPEndpoint | ( | cLuaState::cTableRefPtr && | a_Callbacks | ) |
Creates a new instance of the endpoint, wrapping the callbacks that are in the specified table.
Definition at line 13 of file LuaUDPEndpoint.cpp.
|
overridevirtual |
Definition at line 22 of file LuaUDPEndpoint.cpp.
void cLuaUDPEndpoint::Close | ( | void | ) |
Closes the UDP listener.
Definition at line 104 of file LuaUDPEndpoint.cpp.
void cLuaUDPEndpoint::EnableBroadcasts | ( | void | ) |
Enables outgoing broadcasts to be made using this endpoint.
Definition at line 121 of file LuaUDPEndpoint.cpp.
UInt16 cLuaUDPEndpoint::GetPort | ( | void | ) | const |
Returns the port on which endpoint is listening for incoming data.
Definition at line 69 of file LuaUDPEndpoint.cpp.
bool cLuaUDPEndpoint::IsOpen | ( | void | ) | const |
Returns true if the endpoint is open for incoming data.
Definition at line 86 of file LuaUDPEndpoint.cpp.
|
overrideprotectedvirtual |
Called when an error occurs on the endpoint.
Implements cUDPEndpoint::cCallbacks.
Definition at line 177 of file LuaUDPEndpoint.cpp.
|
overrideprotectedvirtual |
Called when there is an incoming datagram from a remote host.
Implements cUDPEndpoint::cCallbacks.
Definition at line 168 of file LuaUDPEndpoint.cpp.
bool cLuaUDPEndpoint::Open | ( | UInt16 | a_Port, |
cLuaUDPEndpointPtr | a_Self | ||
) |
Opens the endpoint so that it starts listening for incoming data on the specified port.
a_Self is the shared pointer to self that the object keeps to keep itself alive for as long as it needs (for Lua).
Definition at line 38 of file LuaUDPEndpoint.cpp.
void cLuaUDPEndpoint::Release | ( | void | ) |
Called when Lua garbage-collects the object.
Releases the internal SharedPtr to self, so that the instance may be deallocated.
Definition at line 135 of file LuaUDPEndpoint.cpp.
bool cLuaUDPEndpoint::Send | ( | const AString & | a_Data, |
const AString & | a_RemotePeer, | ||
UInt16 | a_RemotePort | ||
) |
Sends the data contained in the string to the specified remote peer.
Returns true if successful, false on immediate failure (queueing the data failed etc.)
Definition at line 52 of file LuaUDPEndpoint.cpp.
|
protected |
Common code called when the endpoint is considered as terminated.
Releases m_Endpoint and m_Callbacks, each when applicable.
Definition at line 148 of file LuaUDPEndpoint.cpp.
|
protected |
The Lua table that holds the callbacks to be invoked.
Definition at line 62 of file LuaUDPEndpoint.h.
|
protected |
|
protected |
SharedPtr to self, so that the object can keep itself alive for as long as it needs (for Lua).
Definition at line 65 of file LuaUDPEndpoint.h.