Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <LuaServerHandle.h>
Public Member Functions | |
void | Close (void) |
Terminates all connections and closes the listening socket. More... | |
cLuaServerHandle (UInt16 a_Port, cLuaState::cTableRefPtr &&a_Callbacks) | |
Creates a new instance of the server handle, wrapping the (listen-) callbacks that are in the specified table. More... | |
bool | IsListening (void) |
Returns true if the server is currently listening. More... | |
void | Release (void) |
Called when Lua garbage-collects the object. More... | |
void | RemoveLink (cLuaTCPLink *a_Link) |
Removes the link from the list of links that the server is currently tracking. More... | |
void | SetServerHandle (cServerHandlePtr a_ServerHandle, cLuaServerHandlePtr a_Self) |
Called by cNetwork::Listen()'s binding. More... | |
virtual | ~cLuaServerHandle () override |
Public Member Functions inherited from cNetwork::cListenCallbacks | |
virtual | ~cListenCallbacks () |
Protected Member Functions | |
virtual void | OnAccepted (cTCPLink &a_Link) override |
Called when the TCP server created with Listen() creates a new link for an incoming connection. More... | |
virtual void | OnError (int a_ErrorCode, const AString &a_ErrorMsg) override |
Called when the socket fails to listen on the specified port. More... | |
virtual cTCPLink::cCallbacksPtr | OnIncomingConnection (const AString &a_RemoteIPAddress, UInt16 a_RemotePort) override |
Called when the TCP server created with Listen() receives a new incoming connection. More... | |
Protected Attributes | |
cLuaState::cTableRefPtr | m_Callbacks |
The Lua table that holds the callbacks to be invoked. More... | |
cLuaTCPLinkPtrs | m_Connections |
All connections that are currently active in this server. More... | |
cCriticalSection | m_CSConnections |
Protects m_Connections against multithreaded access. More... | |
UInt16 | m_Port |
The port on which the server is listening. More... | |
cLuaServerHandlePtr | m_Self |
SharedPtr to self, given out to newly created links. More... | |
cServerHandlePtr | m_ServerHandle |
The cServerHandle around which this instance is wrapped. More... | |
Definition at line 29 of file LuaServerHandle.h.
cLuaServerHandle::cLuaServerHandle | ( | UInt16 | a_Port, |
cLuaState::cTableRefPtr && | a_Callbacks | ||
) |
Creates a new instance of the server handle, wrapping the (listen-) callbacks that are in the specified table.
Definition at line 15 of file LuaServerHandle.cpp.
|
overridevirtual |
Definition at line 25 of file LuaServerHandle.cpp.
void cLuaServerHandle::Close | ( | void | ) |
Terminates all connections and closes the listening socket.
Definition at line 47 of file LuaServerHandle.cpp.
bool cLuaServerHandle::IsListening | ( | void | ) |
Returns true if the server is currently listening.
Definition at line 79 of file LuaServerHandle.cpp.
|
overrideprotectedvirtual |
Called when the TCP server created with Listen() creates a new link for an incoming connection.
Provides the newly created Link that can be used for communication. Called right after a successful OnIncomingConnection().
Implements cNetwork::cListenCallbacks.
Definition at line 153 of file LuaServerHandle.cpp.
|
overrideprotectedvirtual |
Called when the socket fails to listen on the specified port.
Implements cNetwork::cListenCallbacks.
Definition at line 163 of file LuaServerHandle.cpp.
|
overrideprotectedvirtual |
Called when the TCP server created with Listen() receives a new incoming connection.
Returns the link callbacks that the server should use for the newly created link. If a nullptr is returned, the connection is dropped immediately; otherwise a new cTCPLink instance is created and OnAccepted() is called.
Implements cNetwork::cListenCallbacks.
Definition at line 126 of file LuaServerHandle.cpp.
void cLuaServerHandle::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 113 of file LuaServerHandle.cpp.
void cLuaServerHandle::RemoveLink | ( | cLuaTCPLink * | a_Link | ) |
Removes the link from the list of links that the server is currently tracking.
Definition at line 96 of file LuaServerHandle.cpp.
void cLuaServerHandle::SetServerHandle | ( | cServerHandlePtr | a_ServerHandle, |
cLuaServerHandlePtr | a_Self | ||
) |
Called by cNetwork::Listen()'s binding.
Sets the server handle around which this instance is wrapped, and a self SharedPtr for link management.
Definition at line 35 of file LuaServerHandle.cpp.
|
protected |
The Lua table that holds the callbacks to be invoked.
Definition at line 58 of file LuaServerHandle.h.
|
protected |
All connections that are currently active in this server.
Protected by m_CSConnections.
Definition at line 72 of file LuaServerHandle.h.
|
protected |
Protects m_Connections against multithreaded access.
Definition at line 68 of file LuaServerHandle.h.
|
protected |
The port on which the server is listening.
Used mainly for better error reporting.
Definition at line 62 of file LuaServerHandle.h.
|
protected |
SharedPtr to self, given out to newly created links.
Definition at line 75 of file LuaServerHandle.h.
|
protected |
The cServerHandle around which this instance is wrapped.
Definition at line 65 of file LuaServerHandle.h.