Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <ServerHandleImpl.h>
Public Member Functions | |
virtual void | Close (void) override |
Stops the server, no more incoming connections will be accepted. More... | |
virtual bool | IsListening (void) const override |
Returns true if the server has been started correctly and is currently listening for incoming connections. More... | |
virtual | ~cServerHandleImpl () override |
Closes the server, dropping all the connections. More... | |
Public Member Functions inherited from cServerHandle | |
virtual | ~cServerHandle () |
Static Public Member Functions | |
static cServerHandleImplPtr | Listen (UInt16 a_Port, cNetwork::cListenCallbacksPtr a_ListenCallbacks) |
Creates a new server instance listening on the specified port. More... | |
Protected Member Functions | |
cServerHandleImpl (cNetwork::cListenCallbacksPtr a_ListenCallbacks) | |
Creates a new instance with the specified callbacks. More... | |
bool | Listen (UInt16 a_Port) |
Starts listening on the specified port. More... | |
void | RemoveLink (const cTCPLinkImpl *a_Link) |
Removes the specified link from m_Connections. More... | |
Static Protected Member Functions | |
static void | Callback (evconnlistener *a_Listener, evutil_socket_t a_Socket, sockaddr *a_Addr, int a_Len, void *a_Self) |
The callback called by LibEvent upon incoming connection. More... | |
Protected Attributes | |
cTCPLinkImplPtrs | m_Connections |
Container for all currently active connections on this server. More... | |
evconnlistener * | m_ConnListener |
The LibEvent handle representing the main listening socket. More... | |
cCriticalSection | m_CS |
Mutex protecting m_Connections againt multithreaded access. More... | |
int | m_ErrorCode |
Contains the error code for the failure to listen. More... | |
AString | m_ErrorMsg |
Contains the error message for the failure to listen. More... | |
bool | m_IsListening |
Set to true when the server is initialized successfully and is listening for incoming connections. More... | |
cNetwork::cListenCallbacksPtr | m_ListenCallbacks |
The callbacks used to notify about incoming connections. More... | |
evconnlistener * | m_SecondaryConnListener |
The LibEvent handle representing the secondary listening socket (only when side-by-side listening is needed, such as WinXP). More... | |
cServerHandleImplPtr | m_SelfPtr |
The SharedPtr to self, so that it can be passed to created links. More... | |
Private Types | |
using | Super = cServerHandle |
Friends | |
class | cTCPLinkImpl |
Definition at line 34 of file ServerHandleImpl.h.
|
private |
Definition at line 37 of file ServerHandleImpl.h.
|
overridevirtual |
Closes the server, dropping all the connections.
Definition at line 50 of file ServerHandleImpl.cpp.
|
protected |
Creates a new instance with the specified callbacks.
Initializes the internals, but doesn't start listening yet.
Definition at line 37 of file ServerHandleImpl.cpp.
|
staticprotected |
The callback called by LibEvent upon incoming connection.
Definition at line 294 of file ServerHandleImpl.cpp.
|
overridevirtual |
Stops the server, no more incoming connections will be accepted.
All current connections will be shut down (cTCPLink::Shutdown()).
Implements cServerHandle.
Definition at line 66 of file ServerHandleImpl.cpp.
|
inlineoverridevirtual |
Returns true if the server has been started correctly and is currently listening for incoming connections.
Implements cServerHandle.
Definition at line 55 of file ServerHandleImpl.h.
|
protected |
Starts listening on the specified port.
Returns true if successful, false on failure. On failure, sets m_ErrorCode and m_ErrorMsg.
Definition at line 124 of file ServerHandleImpl.cpp.
|
static |
Creates a new server instance listening on the specified port.
Both IPv4 and IPv6 interfaces are used, if possible. Always returns a server instance; in the event of a failure, the instance holds the error details. Use IsListening() to query success.
Definition at line 101 of file ServerHandleImpl.cpp.
|
protected |
Removes the specified link from m_Connections.
Called by cTCPLinkImpl when the link is terminated.
Definition at line 351 of file ServerHandleImpl.cpp.
|
friend |
Definition at line 38 of file ServerHandleImpl.h.
|
protected |
Container for all currently active connections on this server.
Definition at line 71 of file ServerHandleImpl.h.
|
protected |
The LibEvent handle representing the main listening socket.
Definition at line 62 of file ServerHandleImpl.h.
|
protected |
Mutex protecting m_Connections againt multithreaded access.
Definition at line 74 of file ServerHandleImpl.h.
|
protected |
Contains the error code for the failure to listen.
Only valid for non-listening instances.
Definition at line 77 of file ServerHandleImpl.h.
|
protected |
Contains the error message for the failure to listen.
Only valid for non-listening instances.
Definition at line 80 of file ServerHandleImpl.h.
|
protected |
Set to true when the server is initialized successfully and is listening for incoming connections.
Definition at line 68 of file ServerHandleImpl.h.
|
protected |
The callbacks used to notify about incoming connections.
Definition at line 59 of file ServerHandleImpl.h.
|
protected |
The LibEvent handle representing the secondary listening socket (only when side-by-side listening is needed, such as WinXP).
Definition at line 65 of file ServerHandleImpl.h.
|
protected |
The SharedPtr to self, so that it can be passed to created links.
Definition at line 83 of file ServerHandleImpl.h.