12 #include "../OSSupport/Network.h" 81 virtual void OnError(
int a_ErrorCode,
const AString & a_ErrorMsg)
override;
std::unique_ptr< cTableRef > cTableRefPtr
cLuaServerHandle(UInt16 a_Port, cLuaState::cTableRefPtr &&a_Callbacks)
Creates a new instance of the server handle, wrapping the (listen-) callbacks that are in the specifi...
cServerHandlePtr m_ServerHandle
The cServerHandle around which this instance is wrapped.
void SetServerHandle(cServerHandlePtr a_ServerHandle, cLuaServerHandlePtr a_Self)
Called by cNetwork::Listen()'s binding.
void Close(void)
Terminates all connections and closes the listening socket.
virtual ~cLuaServerHandle() override
UInt16 m_Port
The port on which the server is listening.
virtual void OnError(int a_ErrorCode, const AString &a_ErrorMsg) override
Called when the socket fails to listen on the specified port.
std::shared_ptr< cServerHandle > cServerHandlePtr
cLuaState::cTableRefPtr m_Callbacks
The Lua table that holds the callbacks to be invoked.
std::shared_ptr< cLuaTCPLink > cLuaTCPLinkPtr
std::vector< cLuaTCPLinkPtr > cLuaTCPLinkPtrs
std::shared_ptr< cCallbacks > cCallbacksPtr
void RemoveLink(cLuaTCPLink *a_Link)
Removes the link from the list of links that the server is currently tracking.
bool IsListening(void)
Returns true if the server is currently listening.
Callbacks used when listening for incoming connections as a server.
cLuaServerHandlePtr m_Self
SharedPtr to self, given out to newly created links.
Interface that provides the methods available on a single TCP connection.
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.
void Release(void)
Called when Lua garbage-collects the object.
std::shared_ptr< cLuaServerHandle > cLuaServerHandlePtr
cCriticalSection m_CSConnections
Protects m_Connections against multithreaded access.
cLuaTCPLinkPtrs m_Connections
All connections that are currently active in this server.
virtual void OnAccepted(cTCPLink &a_Link) override
Called when the TCP server created with Listen() creates a new link for an incoming connection...