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