|
Cuberite
A lightweight, fast and extensible game server for Minecraft
|
Go to the documentation of this file.
17 #include <netinet/in.h>
57 virtual void OnReceivedData(
const char * a_Data,
size_t a_Length) = 0;
69 virtual void OnError(
int a_ErrorCode,
const AString & a_ErrorMsg) = 0;
79 virtual bool Send(
const void * a_Data,
size_t a_Length) = 0;
85 return Send(a_Data.data(), a_Data.size());
107 virtual void Close(
void) = 0;
163 virtual void Close(
void) = 0;
185 virtual void OnError(
int a_ErrorCode,
const AString & a_ErrorMsg) = 0;
197 virtual void Close(
void) = 0;
200 virtual bool IsOpen(
void)
const = 0;
246 virtual void OnError(
int a_ErrorCode,
const AString & a_ErrorMsg) = 0;
270 virtual void OnError(
int a_ErrorCode,
const AString & a_ErrorMsg) = 0;
302 virtual void OnError(
int a_ErrorCode,
const AString & a_ErrorMsg) = 0;
std::shared_ptr< cResolveNameCallbacks > cResolveNameCallbacksPtr
static cUDPEndpointPtr CreateUDPEndpoint(UInt16 a_Port, cUDPEndpoint::cCallbacks &a_Callbacks)
Opens up an UDP endpoint for sending and receiving UDP datagrams on the specified port.
std::shared_ptr< cX509Cert > cX509CertPtr
virtual void Close(void)=0
Closes the underlying socket.
Interface that provides the methods available on a single TCP connection.
static bool Connect(const AString &a_Host, UInt16 a_Port, cConnectCallbacksPtr a_ConnectCallbacks, cTCPLink::cCallbacksPtr a_LinkCallbacks)
Queues a TCP connection to be made to the specified host.
Callbacks used when listening for incoming connections as a server.
Interface for the callbacks for events that can happen on the endpoint.
virtual void OnError(int a_ErrorCode, const AString &a_ErrorMsg)=0
Called when an error is encountered while resolving.
virtual AString StartTLSServer(cX509CertPtr a_OwnCert, cCryptoKeyPtr a_OwnPrivKey, const AString &a_StartTLSData)=0
Starts a TLS handshake as a server connection.
virtual void OnError(int a_ErrorCode, const AString &a_ErrorMsg)=0
Called when an error is detected on the connection.
virtual AString GetLocalIP(void) const =0
Returns the IP address of the local endpoint of the connection.
virtual void OnNameResolved(const AString &a_Name, const AString &a_IP)=0
Called when the hostname is successfully resolved into an IP address.
virtual bool IsListening(void) const =0
Returns true if the server has been started correctly and is currently listening for incoming connect...
virtual UInt16 GetLocalPort(void) const =0
Returns the port used by the local endpoint of the connection.
Interface that provides the methods available on a listening server socket.
std::vector< cTCPLinkPtr > cTCPLinkPtrs
std::shared_ptr< cTCPLink > cTCPLinkPtr
Callbacks used for connecting to other servers as a client.
std::shared_ptr< cX509Cert > cX509CertPtr
virtual bool Send(const AString &a_Payload, const AString &a_Host, UInt16 a_Port)=0
Sends the specified payload in a single UDP datagram to the specified host + port combination.
static bool IPToHostName(const AString &a_IP, cResolveNameCallbacksPtr a_Callbacks)
Queues a DNS query to resolve the specified IP address to a hostname.
virtual void OnError(int a_ErrorCode, const AString &a_ErrorMsg)=0
Called when the Connect call fails.
virtual void EnableBroadcasts(void)=0
Marks the socket as capable of sending broadcast, using whatever OS API is needed.
virtual void OnReceivedData(const char *a_Data, size_t a_Size, const AString &a_RemoteHost, UInt16 a_RemotePort)=0
Called when there is an incoming datagram from a remote host.
virtual ~cConnectCallbacks()
virtual ~cResolveNameCallbacks()
virtual bool Send(const void *a_Data, size_t a_Length)=0
Queues the specified data for sending to the remote peer.
cCallbacks & m_Callbacks
The callbacks used for various events on the endpoint.
virtual UInt16 GetRemotePort(void) const =0
Returns the port used by the remote endpoint of the connection.
virtual AString StartTLSClient(cX509CertPtr a_OwnCert, cCryptoKeyPtr a_OwnPrivKey)=0
Starts a TLS handshake as a client connection.
virtual bool OnNameResolvedV6(const AString &a_Name, const sockaddr_in6 *a_IP)
Called when the hostname is successfully resolved into an IPv6 address.
bool Send(const AString &a_Data)
Queues the specified data for sending to the remote peer.
cCallbacksPtr m_Callbacks
Callbacks to be used for the various situations.
virtual UInt16 GetPort(void) const =0
Returns the local port to which the underlying socket is bound.
virtual bool IsOpen(void) const =0
Returns true if the endpoint is open.
std::shared_ptr< cCryptoKey > cCryptoKeyPtr
virtual void OnAccepted(cTCPLink &a_Link)=0
Called when the TCP server created with Listen() creates a new link for an incoming connection.
cTCPLink(cCallbacksPtr a_Callbacks)
Creates a new link, with the specified callbacks.
virtual void OnError(int a_ErrorCode, const AString &a_ErrorMsg)=0
Called when an error occurs on the endpoint.
std::shared_ptr< cCallbacks > cCallbacksPtr
cUDPEndpoint(cCallbacks &a_Callbacks)
Creates a new instance of an endpoint, with the specified callbacks.
std::shared_ptr< cCryptoKey > cCryptoKeyPtr
std::shared_ptr< cUDPEndpoint > cUDPEndpointPtr
static AStringVector EnumLocalIPAddresses(void)
Returns all local IP addresses for network interfaces currently available.
virtual cTCPLink::cCallbacksPtr OnIncomingConnection(const AString &a_RemoteIPAddress, UInt16 a_RemotePort)=0
Called when the TCP server created with Listen() receives a new incoming connection.
virtual void OnError(int a_ErrorCode, const AString &a_ErrorMsg)=0
Called when the socket fails to listen on the specified port.
virtual void OnReceivedData(const char *a_Data, size_t a_Length)=0
Called when there's data incoming from the remote peer.
Callbacks used when resolving names to IPs.
static cServerHandlePtr Listen(UInt16 a_Port, cListenCallbacksPtr a_ListenCallbacks)
Opens up the specified port for incoming connections.
virtual void OnRemoteClosed(void)=0
Called when the remote end closes the connection.
Interface that provides methods available on UDP communication endpoints.
std::shared_ptr< cServerHandle > cServerHandlePtr
virtual void Close(void)=0
Drops the connection without any more processing.
virtual void OnFinished(void)=0
Called when all the addresses resolved have been reported via the OnNameResolved() callback.
std::shared_ptr< cConnectCallbacks > cConnectCallbacksPtr
virtual AString GetRemoteIP(void) const =0
Returns the IP address of the remote endpoint of the connection.
std::shared_ptr< cListenCallbacks > cListenCallbacksPtr
virtual bool OnNameResolvedV4(const AString &a_Name, const sockaddr_in *a_IP)
Called when the hostname is successfully resolved into an IPv4 address.
cCallbacksPtr GetCallbacks(void) const
Returns the callbacks that are used.
virtual void OnConnected(cTCPLink &a_Link)=0
Called when the Connect call succeeds.
std::vector< cServerHandlePtr > cServerHandlePtrs
virtual void Close(void)=0
Stops the server, no more incoming connections will be accepted.
virtual void OnLinkCreated(cTCPLinkPtr a_Link)=0
Called when the cTCPLink for the connection is created.
virtual void Shutdown(void)=0
Closes the link gracefully.
static bool HostnameToIP(const AString &a_Hostname, cResolveNameCallbacksPtr a_Callbacks)
Queues a DNS query to resolve the specified hostname to IP address.
virtual void OnTlsHandshakeCompleted(void)
Called when the TLS handshake has been completed and communication can continue regularly.
virtual ~cListenCallbacks()
std::vector< AString > AStringVector