![]() |
Murl Engine API
Version 2018.3
|
The socket client thread interface. More...
#include <murl_net_i_socket_client.h>
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.
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... | |
|
pure virtual |
Get the name of the client.
|
pure virtual |
Get the unique identifier of the client.
|
pure virtual |
Start listening for broadcasts from an ISocketServer.
address | The address to bind for listening. |
|
pure virtual |
Stop listening for broadcasts from an ISocketServer.
Stop listening for broadcasts clears the broadcast packet queue.
|
pure virtual |
Check if the thread is listening for braodcasts.
|
pure virtual |
Get the maximum number of broadcast packets the thread can store.
The default broadcast packets queue length is 10.
|
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.
maxLength | The maximum number of broadcast packets the thread can store. |
|
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.
|
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.
serverBroadcast | The broadcast packet received by GetServerBroadcast(). |
|
pure virtual |
Deny a server broadcast packet.
serverBroadcast | The broadcast packet received by GetServerBroadcast(). |
|
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.
address | The server address to connect to. |
name | The name of the server. |
uniqueId | The unique identifier of the server. |
|
pure virtual |
Disconnect from the server.
|
pure virtual |
Check if the client is connected to a server or connecting to the server is in progress.
|
pure virtual |
Check if the client is connected to a server.
|
pure virtual |
Get detailed information of a connected server.
Send data to the server.
data | The data object to send. |
|
pure virtual |
Get the maximum number of received packets the thread can store.
The default received packets queue length is 20.
|
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.
maxLength | The maximum number of received packets the thread can store. |
|
pure virtual |
Get a received packet from a server.
The packet returned is removed from the received packets queue.
|
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.
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 the client is disconnected.
This is an optional feature for notifying a thread if necessary, typically the app logic is checking IsConnected() 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. |