Murl::Net::ISocketClient Interface Referenceabstract

The socket client thread interface. More...

#include "murl_net_i_socket_client.h"

Inherited by Murl::Net::SocketClient.

Public Member Functions

virtual const StringGetClientName () const =0
 Get the name of the client. More...
 
virtual const StringGetUniqueIdentifier () const =0
 Get the unique identifier of the client. More...
 
virtual Bool StartListenBroadcast (ISocketAddressCPtr address)=0
 Start listening for broadcasts from an ISocketServer. More...
 
virtual Bool StopListenBroadcast ()=0
 Stop listening for broadcasts from an ISocketServer. More...
 
virtual Bool IsListenBroadcast () const =0
 Check if the thread is listening for braodcasts. More...
 
virtual UInt32 GetMaxBroadcastQueueLength () const =0
 Get the maximum number of broadcast packets the thread can store. More...
 
virtual void SetMaxBroadcastQueueLength (UInt32 maxLength)=0
 Set the maximum number of broadcast packet the thread can store. More...
 
virtual void ClearBroadcastQueue ()=0
 Clear the incoming boradcast packets queue.
 
virtual ISocketPacketCPtr GetServerBroadcast ()=0
 Get a broadcast packet from a server. More...
 
virtual Bool AcceptServer (ISocketPacketCPtr serverBroadcast)=0
 Accept a server connection. More...
 
virtual Bool DenyServer (ISocketPacketCPtr serverBroadcast)=0
 Deny a server broadcast packet. More...
 
virtual Bool ConnectToServer (ISocketAddressCPtr address, const String &name, const String &uniqueId)=0
 Connect to a server using an address directly. More...
 
virtual Bool DisconnectServer ()=0
 Disconnect from the server. More...
 
virtual Bool IsConnectedOrConnecting () const =0
 Check if the client is connected to a server or connecting to the server is in progress. More...
 
virtual Bool IsConnected () const =0
 Check if the client is connected to a server. More...
 
virtual ISocketPacketPtr GetServerInfo () const =0
 Get detailed information of a connected server. More...
 
virtual Bool Send (const ConstData &data)=0
 Send data to the server. 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 server. More...
 
virtual void SetReceivedBroadcastMessage (Util::MessageQueue *messageQueue, UInt32 messageId)=0
 Set a message to send when a broadcast packet is received. More...
 
virtual void SetReceivedDisconnectMessage (Util::MessageQueue *messageQueue, UInt32 messageId)=0
 Set a message to send when the 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 client thread interface.

The socket client implements a thread for network communication which can be commanded by a logic implementation.

The client can connect to an ISocketServer either via listening for broadcasts or by specifying an address directly.

If the client is connected to a server, data can be transfered from an to the server simultaneously via the network.

Member Function Documentation

◆ GetClientName()

virtual const String& Murl::Net::ISocketClient::GetClientName ( ) const
pure virtual

Get the name of the client.

Returns
The name of the client.

◆ GetUniqueIdentifier()

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

Get the unique identifier of the client.

Returns
The unique identifier of the client.

◆ StartListenBroadcast()

virtual Bool Murl::Net::ISocketClient::StartListenBroadcast ( ISocketAddressCPtr  address)
pure virtual

Start listening for broadcasts from an ISocketServer.

Parameters
addressThe address to bind for listening.
Returns
true if passing the address was successful or the thread is already listening for broadcasts.

◆ StopListenBroadcast()

virtual Bool Murl::Net::ISocketClient::StopListenBroadcast ( )
pure virtual

Stop listening for broadcasts from an ISocketServer.

Stop listening for broadcasts clears the broadcast packet queue.

Returns
true if passing the command was successful or the thread is not listening for broadcasts.

◆ IsListenBroadcast()

virtual Bool Murl::Net::ISocketClient::IsListenBroadcast ( ) const
pure virtual

Check if the thread is listening for braodcasts.

Returns
true if the thread is listening for braodcasts.

◆ GetMaxBroadcastQueueLength()

virtual UInt32 Murl::Net::ISocketClient::GetMaxBroadcastQueueLength ( ) const
pure virtual

Get the maximum number of broadcast packets the thread can store.

The default broadcast packets queue length is 10.

Returns
The maximum number of broadcast packets the thread can store.

◆ SetMaxBroadcastQueueLength()

virtual void Murl::Net::ISocketClient::SetMaxBroadcastQueueLength ( UInt32  maxLength)
pure virtual

Set the maximum number of broadcast packet the thread can store.

If the given maximum length is smaller than the current maximum length, the broadcast packet queue is cleared. If the broadcast packet queue is full, the oldest packet is discarded.

Parameters
maxLengthThe maximum number of broadcast packets the thread can store.

◆ GetServerBroadcast()

virtual ISocketPacketCPtr Murl::Net::ISocketClient::GetServerBroadcast ( )
pure virtual

Get a broadcast packet from a server.

If the packet returned is not null, the logic can decide depending on the packet information if the client should accept or deny the server. The logic must call AcceptServer() or DenyServer() to remove the packet from the broadcast queue.

Returns
A broadcast packet from a server or null if the broadcast packet queue is empty.

◆ AcceptServer()

virtual Bool Murl::Net::ISocketClient::AcceptServer ( ISocketPacketCPtr  serverBroadcast)
pure virtual

Accept a server connection.

When connecting to the server was successful, listening for broadcasts is stopped and the broadcast packet queue is cleared.

Parameters
serverBroadcastThe broadcast packet received by GetServerBroadcast().
Returns
true if accepting the server was successful.

◆ DenyServer()

virtual Bool Murl::Net::ISocketClient::DenyServer ( ISocketPacketCPtr  serverBroadcast)
pure virtual

Deny a server broadcast packet.

Parameters
serverBroadcastThe broadcast packet received by GetServerBroadcast().
Returns
true if removing the packet from the broadcast queue was successful.

◆ ConnectToServer()

virtual Bool Murl::Net::ISocketClient::ConnectToServer ( ISocketAddressCPtr  address,
const String name,
const String uniqueId 
)
pure virtual

Connect to a server using an address directly.

The parameters name and unique identifier of the server must not be the real server information, these values are simply stored in the received packets to help identifying the sender. When connecting to the server was successful, listening for broadcasts is stopped and the broadcast packet queue is cleared.

Parameters
addressThe server address to connect to.
nameThe name of the server.
uniqueIdThe unique identifier of the server.
Returns
true if passing the command was successful.

◆ DisconnectServer()

virtual Bool Murl::Net::ISocketClient::DisconnectServer ( )
pure virtual

Disconnect from the server.

Returns
true if passing the command was successful.

◆ IsConnectedOrConnecting()

virtual Bool Murl::Net::ISocketClient::IsConnectedOrConnecting ( ) const
pure virtual

Check if the client is connected to a server or connecting to the server is in progress.

Returns
true if the client is connected to a server or connecting to the server is in progress.

◆ IsConnected()

virtual Bool Murl::Net::ISocketClient::IsConnected ( ) const
pure virtual

Check if the client is connected to a server.

Returns
true if the client is connected to a server.

◆ GetServerInfo()

virtual ISocketPacketPtr Murl::Net::ISocketClient::GetServerInfo ( ) const
pure virtual

Get detailed information of a connected server.

Returns
The server information packet.

◆ Send()

virtual Bool Murl::Net::ISocketClient::Send ( const ConstData data)
pure virtual

Send data to the server.

Parameters
dataThe data object to send.
Returns
true if passing the data was successful, false if the client is not connected.

◆ GetMaxReceiveQueueLength()

virtual UInt32 Murl::Net::ISocketClient::GetMaxReceiveQueueLength ( ) const
pure virtual

Get the maximum number of received packets the thread can store.

The default received packets queue length is 20.

Returns
The maximum number of received packets the thread can store.

◆ SetMaxReceiveQueueLength()

virtual void Murl::Net::ISocketClient::SetMaxReceiveQueueLength ( UInt32  maxLength)
pure virtual

Set the maximum number of received packet the thread can store.

Setting the maximum length clears the received packet queue. 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::ISocketClient::GetReceivedData ( )
pure virtual

Get a received packet from a server.

The packet returned is removed from the received packets queue.

Returns
A received packet from a server or null if the received packets queue is empty.

◆ SetReceivedBroadcastMessage()

virtual void Murl::Net::ISocketClient::SetReceivedBroadcastMessage ( Util::MessageQueue messageQueue,
UInt32  messageId 
)
pure virtual

Set a message to send when a broadcast packet is received.

This is an optional feature for notifying a thread if necessary, typically the app logic is checking GetServerBroadcast() each tick.

Parameters
messageQueueThe message queue to post the message or null to disable posting (default).
messageIdThe id of the message to post.

◆ SetReceivedDisconnectMessage()

virtual void Murl::Net::ISocketClient::SetReceivedDisconnectMessage ( Util::MessageQueue messageQueue,
UInt32  messageId 
)
pure virtual

Set a message to send when the client is disconnected.

This is an optional feature for notifying a thread if necessary, typically the app logic is checking IsConnected() 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::ISocketClient::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_client.h


Copyright © 2011-2018 Spraylight GmbH.