ProtonNet Server 1.0
An Open Solution for all your socket or web api needs.
Loading...
Searching...
No Matches
XmobiTea.ProtonNetClient.HttpClient Class Reference

Represents an HTTP client that handles sending requests and receiving responses over a TCP connection. More...

Inheritance diagram for XmobiTea.ProtonNetClient.HttpClient:
XmobiTea.ProtonNetClient.TcpClient XmobiTea.ProtonNetClient.IHttpClient XmobiTea.ProtonNetClient.ITcpClient XmobiTea.ProtonNetClient.IClient XmobiTea.ProtonNetClient.IClient XmobiTea.ProtonNetClient.WsClient XmobiTea.ProtonNet.Client.Socket.Clients.SocketWsClient

Public Member Functions

 HttpClient (string address, int port, TcpClientOptions options)
 Initializes a new instance of the HttpClient class.
 
int SendRequest (HttpRequest request)
 Sends an HTTP request synchronously using the provided request data.
 
bool SendRequestAsync (HttpRequest request)
 Sends an HTTP request asynchronously using the provided request data.
 
- Public Member Functions inherited from XmobiTea.ProtonNetClient.TcpClient
 TcpClient (string address, int port, TcpClientOptions options)
 Initializes a new instance of the TcpClient class.
 
INetworkStatistics GetNetworkStatistics ()
 Gets the network statistics associated with the client.
 
virtual bool Connect ()
 Connects the client to the server synchronously.
 
virtual bool Disconnect ()
 Disconnects the client from the server synchronously.
 
virtual bool Reconnect ()
 Reconnects the client to the server by first disconnecting and then reconnecting.
 
virtual bool ConnectAsync ()
 Connects the client to the server asynchronously.
 
virtual bool DisconnectAsync ()
 Disconnects the client from the server asynchronously.
 
virtual bool ReconnectAsync ()
 Reconnects the client to the server asynchronously by first disconnecting and then reconnecting.
 
virtual int Send (byte[] buffer)
 Sends data to the server synchronously.
 
virtual int Send (byte[] buffer, int position, int length)
 Sends data to the server synchronously starting from a specific position in the buffer.
 
virtual bool SendAsync (byte[] buffer)
 Sends data to the server asynchronously.
 
virtual bool SendAsync (byte[] buffer, int position, int length)
 Sends data to the server asynchronously starting from a specific position in the buffer.
 
void Dispose ()
 Disposes the TCP client, releasing all resources.
 
- Public Member Functions inherited from XmobiTea.ProtonNetClient.IClient
- Public Member Functions inherited from XmobiTea.ProtonNetClient.IHttpClient

Protected Member Functions

override void OnReceived (byte[] buffer, int position, int length)
 Handles data received from the server. Processes HTTP response headers and body data accordingly.
 
override void OnDisconnected ()
 Handles the disconnection event and processes any remaining HTTP response body data.
 
virtual void OnReceivedResponseHeader (HttpResponse response)
 Called when an HTTP response header has been successfully received. Can be overridden in derived classes to handle the event.
 
virtual void OnReceivedResponse (HttpResponse response)
 Called when an entire HTTP response has been successfully received. Can be overridden in derived classes to handle the event.
 
virtual void OnReceivedResponseError (HttpResponse response, string error)
 Called when an error occurs during the processing of an HTTP response. Can be overridden in derived classes to handle the event.
 
- Protected Member Functions inherited from XmobiTea.ProtonNetClient.TcpClient
virtual void OnConnecting ()
 Called when the client is in the process of connecting. Can be overridden in derived classes to handle the event.
 
virtual void OnConnected ()
 Called when the client has successfully connected to the server. Can be overridden in derived classes to handle the event.
 
virtual void OnDisconnecting ()
 Called when the client is in the process of disconnecting. Can be overridden in derived classes to handle the event.
 
virtual void OnSent (int sent, int pending)
 Called when data is successfully sent to the server. Can be overridden in derived classes to handle the event.
 
virtual void OnEmpty ()
 Called when the send buffer is empty. Can be overridden in derived classes to handle the event.
 
virtual void OnError (SocketError error)
 Called when an error occurs during socket operations. Can be overridden in derived classes to handle the event.
 
virtual void Dispose (bool disposingManagedResources)
 Disposes the TCP client, releasing managed resources if specified.
 

Properties

HttpRequest Request [get]
 Gets the current HTTP request being processed by the client.
 
HttpResponse Response [get]
 Gets the current HTTP response received from the server.
 
- Properties inherited from XmobiTea.ProtonNetClient.TcpClient
string Id [get]
 Gets the unique identifier for this TCP client instance.
 
string Address [get]
 Gets the server address to which the client is connected.
 
int Port [get]
 Gets the port number on the server to which the client is connected.
 
EndPoint EndPoint [get]
 Gets the endpoint representing the server's address and port.
 
Socket Socket [get]
 Gets the underlying socket used for the connection.
 
TcpClientOptions Options [get]
 Gets the options used to configure the TCP client.
 
bool IsConnecting [get]
 Gets a value indicating whether the client is currently connecting.
 
bool IsConnected [get]
 Gets a value indicating whether the client is connected to the server.
 
bool IsDisposed [get]
 Gets a value indicating whether the client has been disposed.
 
bool IsSocketDisposed [get]
 Gets a value indicating whether the socket has been disposed.
 

Detailed Description

Represents an HTTP client that handles sending requests and receiving responses over a TCP connection.

Constructor & Destructor Documentation

◆ HttpClient()

XmobiTea.ProtonNetClient.HttpClient.HttpClient ( string address,
int port,
TcpClientOptions options )

Initializes a new instance of the HttpClient class.

Parameters
addressThe server address to connect to.
portThe port number on the server.
optionsTCP client options for configuring the connection.

Member Function Documentation

◆ OnDisconnected()

override void XmobiTea.ProtonNetClient.HttpClient.OnDisconnected ( )
protectedvirtual

Handles the disconnection event and processes any remaining HTTP response body data.

Reimplemented from XmobiTea.ProtonNetClient.TcpClient.

Reimplemented in XmobiTea.ProtonNet.Client.Socket.Clients.SocketWsClient, and XmobiTea.ProtonNetClient.WsClient.

◆ OnReceived()

override void XmobiTea.ProtonNetClient.HttpClient.OnReceived ( byte[] buffer,
int position,
int length )
protectedvirtual

Handles data received from the server. Processes HTTP response headers and body data accordingly.

Parameters
bufferThe buffer containing the received data.
positionThe starting position in the buffer.
lengthThe length of the received data.

Reimplemented from XmobiTea.ProtonNetClient.TcpClient.

Reimplemented in XmobiTea.ProtonNetClient.WsClient.

◆ OnReceivedResponse()

virtual void XmobiTea.ProtonNetClient.HttpClient.OnReceivedResponse ( HttpResponse response)
protectedvirtual

Called when an entire HTTP response has been successfully received. Can be overridden in derived classes to handle the event.

Parameters
responseThe received HTTP response.

Reimplemented in XmobiTea.ProtonNetClient.WsClient.

◆ OnReceivedResponseError()

virtual void XmobiTea.ProtonNetClient.HttpClient.OnReceivedResponseError ( HttpResponse response,
string error )
protectedvirtual

Called when an error occurs during the processing of an HTTP response. Can be overridden in derived classes to handle the event.

Parameters
responseThe received HTTP response that caused the error.
errorA message describing the error.

Reimplemented in XmobiTea.ProtonNetClient.WsClient.

◆ OnReceivedResponseHeader()

virtual void XmobiTea.ProtonNetClient.HttpClient.OnReceivedResponseHeader ( HttpResponse response)
protectedvirtual

Called when an HTTP response header has been successfully received. Can be overridden in derived classes to handle the event.

Parameters
responseThe received HTTP response.

Reimplemented in XmobiTea.ProtonNetClient.WsClient.

◆ SendRequest()

int XmobiTea.ProtonNetClient.HttpClient.SendRequest ( HttpRequest request)

Sends an HTTP request synchronously using the provided request data.

Parameters
requestThe HTTP request to be sent.
Returns
The number of bytes sent.

Implements XmobiTea.ProtonNetClient.IHttpClient.

◆ SendRequestAsync()

bool XmobiTea.ProtonNetClient.HttpClient.SendRequestAsync ( HttpRequest request)

Sends an HTTP request asynchronously using the provided request data.

Parameters
requestThe HTTP request to be sent.
Returns
True if the request was sent successfully; otherwise, false.

Implements XmobiTea.ProtonNetClient.IHttpClient.


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