The socket client thread interface. More...
#include "murl_net_i_socket_client.h"
Inherited by Murl::Net::SocketClient.
Public Member Functions | |
virtual const String & | GetClientName () const =0 |
Get the name of the client. More... | |
virtual const String & | GetUniqueIdentifier () 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()
|
pure virtual |
Get the name of the client.
- Returns
- The name of the client.
◆ GetUniqueIdentifier()
|
pure virtual |
Get the unique identifier of the client.
- Returns
- The unique identifier of the client.
◆ StartListenBroadcast()
|
pure virtual |
Start listening for broadcasts from an ISocketServer.
- Parameters
-
address The address to bind for listening.
- Returns
- true if passing the address was successful or the thread is already listening for broadcasts.
◆ 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()
|
pure virtual |
Check if the thread is listening for braodcasts.
- Returns
- true if the thread is listening for braodcasts.
◆ GetMaxBroadcastQueueLength()
|
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()
|
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
-
maxLength The maximum number of broadcast packets the thread can store.
◆ 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()
|
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
-
serverBroadcast The broadcast packet received by GetServerBroadcast().
- Returns
- true if accepting the server was successful.
◆ DenyServer()
|
pure virtual |
Deny a server broadcast packet.
- Parameters
-
serverBroadcast The broadcast packet received by GetServerBroadcast().
- Returns
- true if removing the packet from the broadcast queue was successful.
◆ ConnectToServer()
|
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
-
address The server address to connect to. name The name of the server. uniqueId The unique identifier of the server.
- Returns
- true if passing the command was successful.
◆ DisconnectServer()
|
pure virtual |
Disconnect from the server.
- Returns
- true if passing the command was successful.
◆ IsConnectedOrConnecting()
|
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()
|
pure virtual |
Check if the client is connected to a server.
- Returns
- true if the client is connected to a server.
◆ GetServerInfo()
|
pure virtual |
Get detailed information of a connected server.
- Returns
- The server information packet.
◆ Send()
Send data to the server.
- Parameters
-
data The data object to send.
- Returns
- true if passing the data was successful, false if the client is not connected.
◆ GetMaxReceiveQueueLength()
|
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()
|
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
-
maxLength The maximum number of received packets the thread can store.
◆ 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()
|
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
-
messageQueue The message queue to post the message or null to disable posting (default). messageId The id of the message to post.
◆ SetReceivedDisconnectMessage()
|
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
-
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_client.h