ProtonNet Server 1.0
An Open Solution for all your socket or web api needs.
Loading...
Searching...
No Matches
XmobiTea.ProtonNet.Client.ClientPeer Class Referenceabstract

Abstract class representing a client peer in the network communication system. Handles sending and receiving of operation requests, managing response timings, and providing debug support. More...

Inheritance diagram for XmobiTea.ProtonNet.Client.ClientPeer:
XmobiTea.ProtonNet.Client.IClientPeer XmobiTea.ProtonNet.Client.Socket.SocketClientPeer XmobiTea.ProtonNet.Client.WebApi.AbstractWebApiClientPeer XmobiTea.ProtonNet.Client.WebApi.HttpClientClientPeer

Public Member Functions

 ClientPeer (string serverAddress, IClientPeerInitRequest initRequest, TcpClientOptions tcpClientOptions)
 Initializes a new instance of the ClientPeer class.
 
INetworkStatistics GetNetworkStatistics ()
 Abstract method to retrieve network statistics for the client peer. Must be implemented by derived classes.
 
int GetClientId ()
 Gets the unique client ID for this client peer.
 
int GetPing ()
 Gets the current ping (round-trip time) to the server.
 
int GetSendRate ()
 Gets the rate at which data is sent by this client peer.
 
void SetSendRate (int sendRate)
 Sets the rate at which data is sent by this client peer.
 
void Send (OperationRequest operationRequest, Action< OperationResponse > onOperationResponse, SendParameters sendParameters, int timeoutInSeconds)
 Sends an operation request to the server.
 
Task< OperationResponseSendAsync (OperationRequest operationRequest, SendParameters sendParameters=default, int timeoutInSeconds=15)
 Asynchronously sends an operation request to the server.
 
virtual bool IsConnected ()
 Determines whether the client peer is currently connected.
 
virtual void Service ()
 Services the client peer, processing any pending tasks or requests.
 
void SetDebugSupport (IDebugSupport debugSupport)
 Sets the debug support for this client peer.
 
void SetAuthToken (string authToken)
 Sets the authentication token for this client peer.
 
- Public Member Functions inherited from XmobiTea.ProtonNet.Client.IClientPeer

Protected Member Functions

void AddWaitingResponseOperationRequestPending (OperationRequestPending operationRequestPending)
 Adds an operation request to the list of those waiting for a response.
 
OperationRequestPending CreateNewOperationRequestPending (OperationRequest operationRequest, Action< OperationResponse > onOperationResponse, SendParameters sendParameters, int timeoutInSeconds)
 Creates a new instance of OperationRequestPending for the given operation request.
 
void SendOperation (OperationRequestPending operationRequestPending)
 Abstract method to send an operation request to the server. Must be implemented by derived classes.
 
void LogEnqueue (OperationRequestPending operationRequestPending)
 Logs the enqueuing of an operation request.
 
void LogSend (OperationRequestPending operationRequestPending)
 Logs the sending of an operation request.
 
void LogRecv (OperationRequestPending operationRequestPending)
 Logs the reception of an operation response.
 

Properties

string logPrefix [get]
 Prefix used in logging messages specific to this client peer.
 
ILogger logger [get]
 Logger instance for logging activities within the client peer.
 
object _lockWaitingResponseOperationRequestPendings [get]
 Lock object to synchronize access to waiting response operation requests.
 
List< OperationRequestPendingwaitingResponseOperationRequestPendings [get]
 List of operation requests that are awaiting a response from the server.
 
object _lockNeedRemoveOperationRequestPendings [get]
 Lock object to synchronize access to operation requests that need to be removed.
 
IDebugSupport debugSupport [get, set]
 Debug support instance for logging and monitoring operations.
 
float updateInterval [get]
 Interval at which updates are sent, in seconds.
 
string authToken [get]
 Authentication token used for server communication.
 
string serverAddress [get]
 Address of the server to which this client peer is connected.
 
string sessionId [get]
 Session ID for the current connection session.
 
int clientId [get]
 Unique client ID assigned to this client peer.
 
IRpcProtocolService rpcProtocolService [get, set]
 RPC protocol service used by this client peer.
 
TcpClientOptions tcpClientOptions [get]
 Options for configuring TCP client connections.
 

Detailed Description

Abstract class representing a client peer in the network communication system. Handles sending and receiving of operation requests, managing response timings, and providing debug support.

Constructor & Destructor Documentation

◆ ClientPeer()

XmobiTea.ProtonNet.Client.ClientPeer.ClientPeer ( string serverAddress,
IClientPeerInitRequest initRequest,
TcpClientOptions tcpClientOptions )

Initializes a new instance of the ClientPeer class.

Parameters
serverAddressThe address of the server to connect to.
initRequestThe initial request containing session and client ID information.
tcpClientOptionsOptions for configuring the TCP client.

Member Function Documentation

◆ AddWaitingResponseOperationRequestPending()

void XmobiTea.ProtonNet.Client.ClientPeer.AddWaitingResponseOperationRequestPending ( OperationRequestPending operationRequestPending)
protected

Adds an operation request to the list of those waiting for a response.

Parameters
operationRequestPendingThe operation request to add.

◆ CreateNewOperationRequestPending()

OperationRequestPending XmobiTea.ProtonNet.Client.ClientPeer.CreateNewOperationRequestPending ( OperationRequest operationRequest,
Action< OperationResponse > onOperationResponse,
SendParameters sendParameters,
int timeoutInSeconds )
protected

Creates a new instance of OperationRequestPending for the given operation request.

Parameters
operationRequestThe operation request to process.
onOperationResponseCallback for handling the server's response.
sendParametersParameters for sending the request.
timeoutInSecondsTimeout for the request in seconds.
Returns
A new instance of OperationRequestPending.

◆ GetClientId()

int XmobiTea.ProtonNet.Client.ClientPeer.GetClientId ( )

Gets the unique client ID for this client peer.

Returns
The client ID as an integer.

Implements XmobiTea.ProtonNet.Client.IClientPeer.

◆ GetNetworkStatistics()

INetworkStatistics XmobiTea.ProtonNet.Client.ClientPeer.GetNetworkStatistics ( )
abstract

Abstract method to retrieve network statistics for the client peer. Must be implemented by derived classes.

Returns
An instance of INetworkStatistics containing network statistics.

Implements XmobiTea.ProtonNet.Client.IClientPeer.

◆ GetPing()

int XmobiTea.ProtonNet.Client.ClientPeer.GetPing ( )

Gets the current ping (round-trip time) to the server.

Returns
The ping in milliseconds.

Implements XmobiTea.ProtonNet.Client.IClientPeer.

◆ GetSendRate()

int XmobiTea.ProtonNet.Client.ClientPeer.GetSendRate ( )

Gets the rate at which data is sent by this client peer.

Returns
The send rate in frames per second.

Implements XmobiTea.ProtonNet.Client.IClientPeer.

◆ IsConnected()

virtual bool XmobiTea.ProtonNet.Client.ClientPeer.IsConnected ( )
virtual

Determines whether the client peer is currently connected.

Returns
True if connected, otherwise false.

Reimplemented in XmobiTea.ProtonNet.Client.Socket.SocketClientPeer, and XmobiTea.ProtonNet.Client.WebApi.AbstractWebApiClientPeer.

◆ LogEnqueue()

void XmobiTea.ProtonNet.Client.ClientPeer.LogEnqueue ( OperationRequestPending operationRequestPending)
protected

Logs the enqueuing of an operation request.

Parameters
operationRequestPendingThe pending operation request to log.

◆ LogRecv()

void XmobiTea.ProtonNet.Client.ClientPeer.LogRecv ( OperationRequestPending operationRequestPending)
protected

Logs the reception of an operation response.

Parameters
operationRequestPendingThe pending operation request to log.

◆ LogSend()

void XmobiTea.ProtonNet.Client.ClientPeer.LogSend ( OperationRequestPending operationRequestPending)
protected

Logs the sending of an operation request.

Parameters
operationRequestPendingThe pending operation request to log.

◆ Send()

void XmobiTea.ProtonNet.Client.ClientPeer.Send ( OperationRequest operationRequest,
Action< OperationResponse > onOperationResponse,
SendParameters sendParameters,
int timeoutInSeconds )

Sends an operation request to the server.

Parameters
operationRequestThe operation request to send.
onOperationResponseCallback for handling the server's response.
sendParametersParameters for sending the request.
timeoutInSecondsTimeout for the request in seconds.

Implements XmobiTea.ProtonNet.Client.IClientPeer.

◆ SendAsync()

Task< OperationResponse > XmobiTea.ProtonNet.Client.ClientPeer.SendAsync ( OperationRequest operationRequest,
SendParameters sendParameters = default,
int timeoutInSeconds = 15 )

Asynchronously sends an operation request to the server.

Parameters
operationRequestThe operation request to send.
sendParametersParameters for sending the request.
timeoutInSecondsTimeout for the request in seconds.
Returns
A Task representing the asynchronous operation, containing the server's response.

Implements XmobiTea.ProtonNet.Client.IClientPeer.

◆ SendOperation()

void XmobiTea.ProtonNet.Client.ClientPeer.SendOperation ( OperationRequestPending operationRequestPending)
abstractprotected

Abstract method to send an operation request to the server. Must be implemented by derived classes.

Parameters
operationRequestPendingThe pending operation request to send.

◆ Service()

virtual void XmobiTea.ProtonNet.Client.ClientPeer.Service ( )
virtual

Services the client peer, processing any pending tasks or requests.

Implements XmobiTea.ProtonNet.Client.IClientPeer.

Reimplemented in XmobiTea.ProtonNet.Client.Socket.SocketClientPeer.

◆ SetAuthToken()

void XmobiTea.ProtonNet.Client.ClientPeer.SetAuthToken ( string authToken)

Sets the authentication token for this client peer.

Parameters
authTokenThe authentication token to set.

Implements XmobiTea.ProtonNet.Client.IClientPeer.

◆ SetDebugSupport()

void XmobiTea.ProtonNet.Client.ClientPeer.SetDebugSupport ( IDebugSupport debugSupport)

Sets the debug support for this client peer.

Parameters
debugSupportThe debug support to set.

Implements XmobiTea.ProtonNet.Client.IClientPeer.

◆ SetSendRate()

void XmobiTea.ProtonNet.Client.ClientPeer.SetSendRate ( int sendRate)

Sets the rate at which data is sent by this client peer.

Parameters
sendRateThe send rate in frames per second.

Implements XmobiTea.ProtonNet.Client.IClientPeer.


The documentation for this class was generated from the following file: