Murl::Net::ISocketServer Interface Referenceabstract

The socket server thread interface. More...

#include "murl_net_i_socket_server.h"

Inherited by Murl::Net::SocketServer.

Public Member Functions

virtual const StringGetServerName () const =0
 Get the name of the server. More...
 
virtual const StringGetUniqueIdentifier () 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()

virtual const String& Murl::Net::ISocketServer::GetServerName ( ) const
pure virtual

Get the name of the server.

Returns
The name of the server.

◆ GetUniqueIdentifier()

virtual const String& Murl::Net::ISocketServer::GetUniqueIdentifier ( ) const
pure virtual

Get the unique identifier of the server.

Returns
The unique identifier of the server.

◆ StartListen()

virtual Bool Murl::Net::ISocketServer::StartListen ( ISocketAddressCPtr  address)
pure virtual

Start listening for incoming ISocketClient connections.

Parameters
addressThe address to bind for listening.
Returns
true if passing the address was successful.

◆ StopListen()

virtual Bool Murl::Net::ISocketServer::StopListen ( )
pure virtual

Stop listening for incomming ISocketClient connections.

Returns
true if passing the command was successful.

◆ StartSendBroadcast()

virtual Bool Murl::Net::ISocketServer::StartSendBroadcast ( ISocketAddressCPtr  address)
pure virtual

Start sending broadcasts.

Before starting broadcasts the listen address must be set by StartListen().

Parameters
addressThe address to send the broadcast.
Returns
true if passing the address was successful.

◆ StopSendBroadcast()

virtual Bool Murl::Net::ISocketServer::StopSendBroadcast ( )
pure virtual

Stop sending broadcasts.

Returns
true if passing the address was successful.

◆ SetBroadcastClock()

virtual void Murl::Net::ISocketServer::SetBroadcastClock ( Double  clockTime)
pure virtual

Set the broacast clock time.

The default clock time is 1 second. Every clockTime seconds one broadcast packet is sent.

Parameters
clockTimeThe broacast send clock time in seconds.

◆ GetMaxAcceptQueueLength()

virtual UInt32 Murl::Net::ISocketServer::GetMaxAcceptQueueLength ( ) const
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()

virtual void Murl::Net::ISocketServer::SetMaxAcceptQueueLength ( UInt32  maxLength)
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
maxLengthThe maximum number of accept packets the thread can store.

◆ GetClientToAccept()

virtual ISocketPacketCPtr Murl::Net::ISocketServer::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()

virtual Bool Murl::Net::ISocketServer::AcceptClient ( ISocketPacketCPtr  clientToAccept)
pure virtual

Accept a client connection.

Parameters
clientToAcceptThe accept packet received by GetClientToAccept().
Returns
true if accepting the client was successful.

◆ DenyClient()

virtual Bool Murl::Net::ISocketServer::DenyClient ( ISocketPacketCPtr  clientToDeny)
pure virtual

Deny a client accept packet.

Parameters
clientToDenyThe accept packet received by GetClientToAccept().
Returns
true if removing the packet from the accept queue was successful.

◆ GetNumberOfConnectedClients()

virtual UInt32 Murl::Net::ISocketServer::GetNumberOfConnectedClients ( ) const
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()

virtual Bool Murl::Net::ISocketServer::HasAcceptedClientsChanged ( ChangeInspector inspector) const
pure virtual

Check if the accepted clients list has changed.

Parameters
inspectorThe inspector to check.
Returns
true if the accepted clients list has changed.

◆ GetAcceptedClients()

virtual void Murl::Net::ISocketServer::GetAcceptedClients ( StringArray clientIds) const
pure virtual

Get the unique identifiers of all accepted clients.

Use HasAcceptedClientsChanged() to check for changes.

Parameters
clientIdsThe identifier string array return value.

◆ GetClientInfo()

virtual ISocketPacketPtr Murl::Net::ISocketServer::GetClientInfo ( const String clientId) const
pure virtual

Get detailed information of a connected client.

The GetAcceptedClients() method returns all accepted client identifiers.

Parameters
clientIdThe unique identifier of the client.
Returns
The client information packet or null if the identifier is not found.

◆ Disconnect()

virtual Bool Murl::Net::ISocketServer::Disconnect ( const String clientId)
pure virtual

Disconnect a client.

The GetAcceptedClients() method returns all accepted client identifiers.

Parameters
clientIdThe unique identifier of the client.
Returns
true if passing the command was successful, false if the client is not found.

◆ Send()

virtual Bool Murl::Net::ISocketServer::Send ( const ConstData data,
const String clientId 
)
pure virtual

Send data to a client.

The GetAcceptedClients() method returns all accepted client identifiers.

Parameters
dataThe data object to send.
clientIdThe unique identifier of the client.
Returns
true if passing the data was successful, false if the client is not found.

◆ GetMaxReceiveQueueLength()

virtual UInt32 Murl::Net::ISocketServer::GetMaxReceiveQueueLength ( ) const
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()

virtual void Murl::Net::ISocketServer::SetMaxReceiveQueueLength ( UInt32  maxLength)
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
maxLengthThe maximum number of received packets the thread can store.

◆ GetReceivedData()

virtual ISocketPacketPtr Murl::Net::ISocketServer::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()

virtual void Murl::Net::ISocketServer::SetReceivedClientToAcceptMessage ( Util::MessageQueue messageQueue,
UInt32  messageId 
)
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
messageQueueThe message queue to post the message or null to disable posting (default).
messageIdThe id of the message to post.

◆ SetReceivedClientDisconnectMessage()

virtual void Murl::Net::ISocketServer::SetReceivedClientDisconnectMessage ( Util::MessageQueue messageQueue,
UInt32  messageId 
)
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
messageQueueThe message queue to post the message or null to disable posting (default).
messageIdThe id of the message to post.

◆ SetReceivedDataMessage()

virtual void Murl::Net::ISocketServer::SetReceivedDataMessage ( Util::MessageQueue messageQueue,
UInt32  messageId 
)
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
messageQueueThe message queue to post the message or null to disable posting (default).
messageIdThe id of the message to post.

The documentation for this interface was generated from the following file:
  • murl_net_i_socket_server.h


Copyright © 2011-2024 Spraylight GmbH.