8 #ifndef FACEBOOK_NETWORK_CONNECTION_ORIENTED_SERVER_H
9 #define FACEBOOK_NETWORK_CONNECTION_ORIENTED_SERVER_H
94 inline const Address4& address()
const;
100 inline const Port& port()
const;
This class wraps an address number with 32 bits.
Definition: Address4.h:26
Definition of a connection object holding the socket and remote address and port.
Definition: ConnectionOrientedServer.h:71
const Address4 & address() const
Returns the remote address of this connection object.
Definition: ConnectionOrientedServer.h:249
Port port_
Remote port of the connection.
Definition: ConnectionOrientedServer.h:111
SocketId id() const
Returns the socket id of this connection object.
Definition: ConnectionOrientedServer.h:244
ConnectionObject()=default
Creates an empty connection object.
Address4 address_
Remote address of the connection.
Definition: ConnectionOrientedServer.h:108
const Port & port() const
Returns the remote port of this connection object.
Definition: ConnectionOrientedServer.h:254
This class is the base class for all connection oriented servers.
Definition: ConnectionOrientedServer.h:28
void setConnectionRequestCallback(const ConnectionRequestCallback &callback)
Sets the connection request callback function.
Definition: ConnectionOrientedServer.h:259
virtual SocketResult send(const ConnectionId connectionId, const std::string &message)
Sends a message over a specified connection.
void setDisconnectCallback(const DisconnectCallback &callback)
Sets the disconnect callback function.
Definition: ConnectionOrientedServer.h:265
virtual size_t connections() const
Returns the number of active connections of this server.
ConnectionRequestCallback connectionRequestCallback_
Connection request callback function.
Definition: ConnectionOrientedServer.h:222
Callback< void, const ConnectionId > DisconnectCallback
Definition of a disconnect callback function.
Definition: ConnectionOrientedServer.h:55
ReceiveCallback receiveCallback_
Receive callback function.
Definition: ConnectionOrientedServer.h:228
unsigned int ConnectionId
Definition of a connection id.
Definition: ConnectionOrientedServer.h:34
DisconnectCallback disconnectCallback_
Disconnect callback function.
Definition: ConnectionOrientedServer.h:225
virtual SocketResult send(const ConnectionId connectionId, const void *data, const size_t size)
Sends data over a specified connection.
bool onScheduler() override
The scheduler event function.
virtual size_t onSend(const ConnectionId connectionId, const void *data, const size_t size)
Internal event function to send data.
Callback< void, const ConnectionId, const void *, const size_t > ReceiveCallback
Definition of a receive callback function.
Definition: ConnectionOrientedServer.h:63
ConnectionOrientedServer()
Creates a new connection oriented server.
Callback< bool, const Address4 &, const Port &, const ConnectionId > ConnectionRequestCallback
Definition of a connection request callback function.
Definition: ConnectionOrientedServer.h:49
~ConnectionOrientedServer() override
Destructs a connection oriented server.
static constexpr ConnectionId invalidConnectionId()
Returns an invalid connection id.
Definition: ConnectionOrientedServer.h:231
virtual bool disconnect(const ConnectionId connectionId)=0
Disconnects a specified connection.
std::unordered_map< ConnectionId, ConnectionObject > ConnectionMap
Definition of a map mapping connection ids to sockets.
Definition: ConnectionOrientedServer.h:117
ConnectionMap connectionMap_
Map holding all valid connections.
Definition: ConnectionOrientedServer.h:216
bool connectionProperties(const ConnectionId connectionId, Address4 &address, Port &port)
Returns the remote address and port of a specified connection.
void setReceiveCallback(const ReceiveCallback &callback)
Sets the receive callback function.
Definition: ConnectionOrientedServer.h:271
virtual void onReceived(const ConnectionId connectionId, const void *data, const size_t size)
Internal event function for received data.
This class wraps a port number with 16 bits.
Definition: Port.h:26
This class is the base class for all server.
Definition: Server.h:26
SocketId socketId_
Socket id.
Definition: Socket.h:184
SOCKET SocketId
Definition of a socket id.
Definition: Socket.h:42
SocketResult
Definition of individual result values.
Definition: Socket.h:62
Lock lock_
Socket lock.
Definition: Socket.h:187
This class implements a scoped lock object for recursive lock objects.
Definition: Lock.h:135
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15