![]() |
Murl Engine API
Version 2018.3
|
The socket server thread interface. More...
#include <murl_net_i_socket_server.h>
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.
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... | |
|
pure virtual |
Get the name of the server.
|
pure virtual |
Get the unique identifier of the server.
|
pure virtual |
Start listening for incoming ISocketClient connections.
address | The address to bind for listening. |
|
pure virtual |
Stop listening for incomming ISocketClient connections.
|
pure virtual |
Start sending broadcasts.
Before starting broadcasts the listen address must be set by StartListen().
address | The address to send the broadcast. |
|
pure virtual |
Stop sending broadcasts.
|
pure virtual |
Set the broacast clock time.
The default clock time is 1 second. Every clockTime seconds one broadcast packet is sent.
clockTime | The broacast send clock time in seconds. |
|
pure virtual |
Get the maximum number of accept packets the thread can store.
The default accept packets queue length is 50.
|
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.
maxLength | The maximum number of accept packets the thread can store. |
|
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.
|
pure virtual |
Accept a client connection.
clientToAccept | The accept packet received by GetClientToAccept(). |
|
pure virtual |
Deny a client accept packet.
clientToDeny | The accept packet received by GetClientToAccept(). |
|
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.
|
pure virtual |
Check if the accepted clients list has changed.
inspector | The inspector to check. |
|
pure virtual |
Get the unique identifiers of all accepted clients.
Use HasAcceptedClientsChanged() to check for changes.
clientIds | The identifier string array return value. |
|
pure virtual |
Get detailed information of a connected client.
The GetAcceptedClients() method returns all accepted client identifiers.
clientId | The unique identifier of the client. |
Disconnect a client.
The GetAcceptedClients() method returns all accepted client identifiers.
clientId | The unique identifier of the client. |
|
pure virtual |
Send data to a client.
The GetAcceptedClients() method returns all accepted client identifiers.
data | The data object to send. |
clientId | The unique identifier of the client. |
|
pure virtual |
Get the maximum number of received packets the thread can store.
The default received packets queue length is 50.
|
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.
maxLength | The maximum number of received packets the thread can store. |
|
pure virtual |
Get a received packet from a client.
The packet returned is removed from the received packets queue.
|
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.
messageQueue | The message queue to post the message or null to disable posting (default). |
messageId | The id of the message to post. |
|
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.
messageQueue | The message queue to post the message or null to disable posting (default). |
messageId | The id of the message to post. |
|
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.
messageQueue | The message queue to post the message or null to disable posting (default). |
messageId | The id of the message to post. |