The socket server thread interface. More...
#include "murl_net_i_socket_server.h"
Inherited by Murl::Net::SocketServer.
Public Member Functions | |
virtual const String & | GetServerName () const =0 |
Get the name of the server. More... | |
virtual const String & | GetUniqueIdentifier () const =0 |
Get the unique identifier of the server. More... | |
virtual Bool | StartListen (ISocketAddressCPtr address)=0 |
Start listening for incoming ISocketClient connections. More... | |
virtual Bool | StopListen ()=0 |
Stop listening for incomming ISocketClient connections. More... | |
virtual Bool | StartSendBroadcast (ISocketAddressCPtr address)=0 |
Start sending broadcasts. More... | |
virtual Bool | StopSendBroadcast ()=0 |
Stop sending broadcasts. More... | |
virtual void | SetBroadcastClock (Double clockTime)=0 |
Set the broacast clock time. More... | |
virtual UInt32 | GetMaxAcceptQueueLength () const =0 |
Get the maximum number of accept packets the thread can store. More... | |
virtual void | SetMaxAcceptQueueLength (UInt32 maxLength)=0 |
Set the maximum number of accept packet the thread can store. More... | |
virtual void | ClearAcceptQueue ()=0 |
Clear the accept packets queue. | |
virtual ISocketPacketCPtr | GetClientToAccept ()=0 |
Get an accept packet from a client. More... | |
virtual Bool | AcceptClient (ISocketPacketCPtr clientToAccept)=0 |
Accept a client connection. More... | |
virtual Bool | DenyClient (ISocketPacketCPtr clientToDeny)=0 |
Deny a client accept packet. More... | |
virtual UInt32 | GetNumberOfConnectedClients () const =0 |
Get the number of connected clients. More... | |
virtual Bool | HasAcceptedClientsChanged (ChangeInspector &inspector) const =0 |
Check if the accepted clients list has changed. More... | |
virtual void | GetAcceptedClients (StringArray &clientIds) const =0 |
Get the unique identifiers of all accepted clients. More... | |
virtual ISocketPacketPtr | GetClientInfo (const String &clientId) const =0 |
Get detailed information of a connected client. More... | |
virtual Bool | Disconnect (const String &clientId)=0 |
Disconnect a client. More... | |
virtual Bool | Send (const ConstData &data, const String &clientId)=0 |
Send data to a client. More... | |
virtual UInt32 | GetMaxReceiveQueueLength () const =0 |
Get the maximum number of received packets the thread can store. More... | |
virtual void | SetMaxReceiveQueueLength (UInt32 maxLength)=0 |
Set the maximum number of received packet the thread can store. More... | |
virtual void | ClearReceiveQueue ()=0 |
Clear the received packets queue. | |
virtual ISocketPacketPtr | GetReceivedData ()=0 |
Get a received packet from a client. More... | |
virtual void | SetReceivedClientToAcceptMessage (Util::MessageQueue *messageQueue, UInt32 messageId)=0 |
Set a message to send when a client to accept packet is received. More... | |
virtual void | SetReceivedClientDisconnectMessage (Util::MessageQueue *messageQueue, UInt32 messageId)=0 |
Set a message to send when a client is disconnected. More... | |
virtual void | SetReceivedDataMessage (Util::MessageQueue *messageQueue, UInt32 messageId)=0 |
Set a message to send when a data packet is received. More... | |
Detailed Description
The socket server thread interface.
The socket server implements a thread for network communication which can be commanded by a logic implementation.
The server supports sending broadcasts for client connections and can hold connections to any number of ISocketClients.
If the server is connected to a client, data can be transfered from an to the client simultaneously via the network.
Member Function Documentation
◆ GetServerName()
|
pure virtual |
Get the name of the server.
- Returns
- The name of the server.
◆ GetUniqueIdentifier()
|
pure virtual |
Get the unique identifier of the server.
- Returns
- The unique identifier of the server.
◆ StartListen()
|
pure virtual |
Start listening for incoming ISocketClient connections.
- Parameters
-
address The address to bind for listening.
- Returns
- true if passing the address was successful.
◆ StopListen()
|
pure virtual |
Stop listening for incomming ISocketClient connections.
- Returns
- true if passing the command was successful.
◆ StartSendBroadcast()
|
pure virtual |
Start sending broadcasts.
Before starting broadcasts the listen address must be set by StartListen().
- Parameters
-
address The address to send the broadcast.
- Returns
- true if passing the address was successful.
◆ StopSendBroadcast()
|
pure virtual |
Stop sending broadcasts.
- Returns
- true if passing the address was successful.
◆ SetBroadcastClock()
|
pure virtual |
Set the broacast clock time.
The default clock time is 1 second. Every clockTime seconds one broadcast packet is sent.
- Parameters
-
clockTime The broacast send clock time in seconds.
◆ GetMaxAcceptQueueLength()
|
pure virtual |
Get the maximum number of accept packets the thread can store.
The default accept packets queue length is 50.
- Returns
- The maximum number of accept packets the thread can store.
◆ SetMaxAcceptQueueLength()
|
pure virtual |
Set the maximum number of accept packet the thread can store.
If the given maximum length is smaller than the current maximum length, the accept packet queue is cleared. If the accept packet queue is full, the client is denied.
- Parameters
-
maxLength The maximum number of accept packets the thread can store.
◆ GetClientToAccept()
|
pure virtual |
Get an accept packet from a client.
If the packet returned is not null, the logic can decide depending on the packet information if the server should accept or deny the client. The logic must call AcceptClient() or DenyClient() to remove the packet from the accept queue.
- Returns
- An accept packet from a client or null if the accept packet queue is empty.
◆ AcceptClient()
|
pure virtual |
Accept a client connection.
- Parameters
-
clientToAccept The accept packet received by GetClientToAccept().
- Returns
- true if accepting the client was successful.
◆ DenyClient()
|
pure virtual |
Deny a client accept packet.
- Parameters
-
clientToDeny The accept packet received by GetClientToAccept().
- Returns
- true if removing the packet from the accept queue was successful.
◆ GetNumberOfConnectedClients()
|
pure virtual |
Get the number of connected clients.
The number of connected clients includes all accepted clients plus the number of clients waiting in the accept queue.
- Returns
- The number of connected clients.
◆ HasAcceptedClientsChanged()
|
pure virtual |
Check if the accepted clients list has changed.
- Parameters
-
inspector The inspector to check.
- Returns
- true if the accepted clients list has changed.
◆ GetAcceptedClients()
|
pure virtual |
Get the unique identifiers of all accepted clients.
Use HasAcceptedClientsChanged() to check for changes.
- Parameters
-
clientIds The identifier string array return value.
◆ GetClientInfo()
|
pure virtual |
Get detailed information of a connected client.
The GetAcceptedClients() method returns all accepted client identifiers.
- Parameters
-
clientId The unique identifier of the client.
- Returns
- The client information packet or null if the identifier is not found.
◆ Disconnect()
Disconnect a client.
The GetAcceptedClients() method returns all accepted client identifiers.
- Parameters
-
clientId The unique identifier of the client.
- Returns
- true if passing the command was successful, false if the client is not found.
◆ Send()
|
pure virtual |
Send data to a client.
The GetAcceptedClients() method returns all accepted client identifiers.
- Parameters
-
data The data object to send. clientId The unique identifier of the client.
- Returns
- true if passing the data was successful, false if the client is not found.
◆ GetMaxReceiveQueueLength()
|
pure virtual |
Get the maximum number of received packets the thread can store.
The default received packets queue length is 50.
- Returns
- The maximum number of received packets the thread can store.
◆ SetMaxReceiveQueueLength()
|
pure virtual |
Set the maximum number of received packet the thread can store.
If the given maximum length is smaller than the current maximum length, the received packet queue is cleared. If the received packet queue is full, the oldest packet is discarded.
- Parameters
-
maxLength The maximum number of received packets the thread can store.
◆ GetReceivedData()
|
pure virtual |
Get a received packet from a client.
The packet returned is removed from the received packets queue.
- Returns
- A received packet from a client or null if the received packets queue is empty.
◆ SetReceivedClientToAcceptMessage()
|
pure virtual |
Set a message to send when a client to accept packet is received.
This is an optional feature for notifying a thread if necessary, typically the app logic is checking GetClientToAccept() each tick.
- Parameters
-
messageQueue The message queue to post the message or null to disable posting (default). messageId The id of the message to post.
◆ SetReceivedClientDisconnectMessage()
|
pure virtual |
Set a message to send when a client is disconnected.
This is an optional feature for notifying a thread if necessary, typically the app logic is checking HasAcceptedClientsChanged() each tick.
- Parameters
-
messageQueue The message queue to post the message or null to disable posting (default). messageId The id of the message to post.
◆ SetReceivedDataMessage()
|
pure virtual |
Set a message to send when a data packet is received.
This is an optional feature for notifying a thread if necessary, typically the app logic is checking GetReceivedData() each tick.
- Parameters
-
messageQueue The message queue to post the message or null to disable posting (default). messageId The id of the message to post.
The documentation for this interface was generated from the following file:
- murl_net_i_socket_server.h