ProtonNet Server 1.0
An Open Solution for all your socket or web api needs.
|
Implements a WebSocket Secure (WSS) client over an HTTPS connection. Supports both synchronous and asynchronous operations. More...
Public Member Functions | |
WssClient (string address, int port, TcpClientOptions options, SslOptions sslOptions) | |
Initializes a new instance of the WssClient class. | |
override bool | Connect () |
Establishes a synchronous connection to the WebSocket server. | |
override bool | ConnectAsync () |
Establishes an asynchronous connection to the WebSocket server. | |
int | SendText (byte[] buffer) |
Sends a text message synchronously to the server. | |
int | SendText (byte[] buffer, int position, int length) |
Sends a text message synchronously to the server. | |
bool | SendTextAsync (byte[] buffer) |
Sends a text message asynchronously to the server. | |
bool | SendTextAsync (byte[] buffer, int position, int length) |
Sends a text message asynchronously to the server. | |
int | SendBinary (byte[] buffer) |
Sends a binary message synchronously to the server. | |
int | SendBinary (byte[] buffer, int position, int length) |
Sends a binary message synchronously to the server. | |
bool | SendBinaryAsync (byte[] buffer) |
Sends a binary message asynchronously to the server. | |
bool | SendBinaryAsync (byte[] buffer, int position, int length) |
Sends a binary message asynchronously to the server. | |
int | SendClose (int status, byte[] buffer) |
Sends a close frame with a status code synchronously to the server. | |
int | SendClose (int status, byte[] buffer, int position, int length) |
Sends a close frame with a status code synchronously to the server. | |
bool | SendCloseAsync (int status, byte[] buffer) |
Sends a close frame with a status code asynchronously to the server. | |
bool | SendCloseAsync (int status, byte[] buffer, int position, int length) |
Sends a close frame with a status code asynchronously to the server. | |
int | SendPing (byte[] buffer) |
Sends a ping frame synchronously to the server. | |
int | SendPing (byte[] buffer, int position, int length) |
Sends a ping frame synchronously to the server. | |
bool | SendPingAsync (byte[] buffer) |
Sends a ping frame asynchronously to the server. | |
bool | SendPingAsync (byte[] buffer, int position, int length) |
Sends a ping frame asynchronously to the server. | |
int | SendPong (byte[] buffer) |
Sends a pong frame synchronously to the server. | |
int | SendPong (byte[] buffer, int position, int length) |
Sends a pong frame synchronously to the server. | |
bool | SendPongAsync (byte[] buffer) |
Sends a pong frame asynchronously to the server. | |
bool | SendPongAsync (byte[] buffer, int position, int length) |
Sends a pong frame asynchronously to the server. | |
virtual void | OnWsConnecting (HttpRequest request) |
Prepares the WebSocket connection by setting the necessary headers. | |
virtual void | OnWsConnected (HttpResponse response) |
Called when the WebSocket connection is successfully established. | |
virtual void | OnWsConnected (HttpRequest request) |
Called when the WebSocket connection is successfully established. | |
virtual bool | OnWsConnecting (HttpRequest request, HttpResponse response) |
OnWsConnecting. | |
virtual void | OnWsDisconnecting () |
Called when the WebSocket connection is in the process of disconnecting. | |
virtual void | OnWsDisconnected () |
Called when the WebSocket connection is successfully disconnected. | |
virtual void | OnWsReceived (byte[] buffer, int position, int length) |
Processes the WebSocket frames received from the server. | |
virtual void | OnWsClose (byte[] buffer, int position, int length, int status=1000) |
Handles a close frame received from the server. | |
virtual void | OnWsPing (byte[] buffer, int position, int length) |
Handles a ping frame received from the server by sending a pong frame. | |
virtual void | OnWsPong (byte[] buffer, int position, int length) |
Handles a pong frame received from the server. | |
virtual void | OnWsError (string error) |
Handles a WebSocket error by reporting it to the client. | |
virtual void | OnWsError (SocketError error) |
Handles a WebSocket error by reporting it to the client. | |
void | SendUpgrade (HttpResponse response) |
Upgrades the HTTP connection to a WebSocket connection. | |
Public Member Functions inherited from XmobiTea.ProtonNetClient.HttpsClient | |
HttpsClient (string address, int port, TcpClientOptions options, SslOptions sslOptions) | |
Initializes a new instance of the HttpsClient 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.SslClient | |
SslClient (string address, int port, TcpClientOptions options, SslOptions sslOptions) | |
Initializes a new instance of the SslClient class. | |
INetworkStatistics | GetNetworkStatistics () |
Gets the network statistics associated with the client. | |
virtual bool | Disconnect () |
Disconnects the client from the server synchronously. | |
virtual bool | Reconnect () |
Reconnects the client to the server by first disconnecting, then reconnecting and initiating the SSL/TLS handshake. | |
virtual bool | DisconnectAsync () |
Disconnects the client from the server asynchronously. | |
virtual bool | ReconnectAsync () |
Reconnects the client to the server asynchronously by first disconnecting, then reconnecting and initiating the SSL/TLS handshake. | |
virtual int | Send (byte[] buffer) |
Sends data to the server synchronously through the SSL/TLS stream. | |
virtual int | Send (byte[] buffer, int position, int length) |
Sends data to the server synchronously through the SSL/TLS stream starting from a specific position in the buffer. | |
virtual bool | SendAsync (byte[] buffer) |
Sends data to the server asynchronously through the SSL/TLS stream. | |
virtual bool | SendAsync (byte[] buffer, int position, int length) |
Sends data to the server asynchronously through the SSL/TLS stream starting from a specific position in the buffer. | |
void | Dispose () |
Disposes the SSL client, releasing all resources. | |
Public Member Functions inherited from XmobiTea.ProtonNetClient.IClient | |
Public Member Functions inherited from XmobiTea.ProtonNetClient.IHttpClient | |
Public Member Functions inherited from XmobiTea.ProtonNetCommon.IWebSocket | |
Public Member Functions inherited from XmobiTea.ProtonNetClient.IWsClient |
Protected Member Functions | |
override void | OnConnecting () |
Called when the client is in the process of connecting to the server. | |
override void | OnConnected () |
Called when the client has successfully connected to the server. | |
override void | OnHandshaking () |
Called when the SSL/TLS handshake is in progress. | |
override void | OnHandshaked () |
Called when the SSL/TLS handshake is successfully completed. | |
override void | OnDisconnecting () |
Called when the client is in the process of disconnecting. | |
override void | OnDisconnected () |
Called when the client has successfully disconnected from the server. | |
override void | OnReceived (byte[] buffer, int position, int length) |
Processes the data received from the server. | |
override void | OnReceivedResponseHeader (HttpResponse response) |
Processes the response header received from the server. | |
override void | OnReceivedResponse (HttpResponse response) |
Processes the response body received from the server. | |
override void | OnReceivedResponseError (HttpResponse response, string error) |
Handles errors in the response received from the server. | |
Protected Member Functions inherited from XmobiTea.ProtonNetClient.HttpsClient | |
Protected Member Functions inherited from XmobiTea.ProtonNetClient.SslClient | |
virtual void | OnSent (int sent, int pending) |
Called when data is successfully sent to the server through the SSL/TLS stream. 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 SSL client, releasing managed resources if specified. | |
Properties | |
byte[] | WsNonce [get] |
Gets the WebSocket nonce used during the handshake. | |
Properties inherited from XmobiTea.ProtonNetClient.HttpsClient | |
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.SslClient | |
SslOptions | SslOptions [get] |
Gets the Ssl options used for SSL/TLS encryption and authentication. | |
bool | IsHandshaking [get] |
Gets a value indicating whether the SSL/TLS handshake is in progress. | |
bool | IsHandshaked [get] |
Gets a value indicating whether the SSL/TLS handshake has been completed. | |
string | Id [get] |
A unique identifier for this client instance. | |
string | Address [get] |
The address of the remote server to which the client is connecting. | |
int | Port [get] |
The port number on the remote server to which the client is connecting. | |
EndPoint | EndPoint [get] |
The endpoint representing the address and port of the remote server. | |
Socket | Socket [get] |
The socket used for network communication. | |
TcpClientOptions | Options [get] |
Configuration options for the TCP client. | |
bool | IsConnecting [get] |
Indicates whether the client is currently in the process of connecting. | |
bool | IsConnected [get] |
Indicates whether the client is currently connected to the server. | |
bool | IsDisposed [get] |
Indicates whether the client has been disposed. | |
bool | IsSocketDisposed [get] |
Indicates whether the socket has been disposed. | |
Implements a WebSocket Secure (WSS) client over an HTTPS connection. Supports both synchronous and asynchronous operations.
XmobiTea.ProtonNetClient.WssClient.WssClient | ( | string | address, |
int | port, | ||
TcpClientOptions | options, | ||
SslOptions | sslOptions ) |
Initializes a new instance of the WssClient class.
address | The server address to connect to. |
port | The port number on the server. |
options | TCP client options for configuring the connection. |
sslOptions | The Ssl options used for establishing the secure connection. |
|
virtual |
Establishes a synchronous connection to the WebSocket server.
Reimplemented from XmobiTea.ProtonNetClient.SslClient.
|
virtual |
Establishes an asynchronous connection to the WebSocket server.
Reimplemented from XmobiTea.ProtonNetClient.SslClient.
|
protectedvirtual |
Called when the client has successfully connected to the server.
Reimplemented from XmobiTea.ProtonNetClient.SslClient.
|
protectedvirtual |
Called when the client is in the process of connecting to the server.
Reimplemented from XmobiTea.ProtonNetClient.SslClient.
|
protectedvirtual |
Called when the client has successfully disconnected from the server.
Reimplemented from XmobiTea.ProtonNetClient.HttpsClient.
|
protectedvirtual |
Called when the client is in the process of disconnecting.
Reimplemented from XmobiTea.ProtonNetClient.SslClient.
|
protectedvirtual |
Called when the SSL/TLS handshake is successfully completed.
Reimplemented from XmobiTea.ProtonNetClient.SslClient.
|
protectedvirtual |
Called when the SSL/TLS handshake is in progress.
Reimplemented from XmobiTea.ProtonNetClient.SslClient.
|
protectedvirtual |
Processes the data received from the server.
buffer | The buffer containing the received data. |
position | The starting position in the buffer. |
length | The length of the received data. |
Reimplemented from XmobiTea.ProtonNetClient.HttpsClient.
|
protectedvirtual |
Processes the response body received from the server.
response | The HTTP response received. |
Reimplemented from XmobiTea.ProtonNetClient.HttpsClient.
|
protectedvirtual |
Handles errors in the response received from the server.
response | The HTTP response that caused the error. |
error | The error message. |
Reimplemented from XmobiTea.ProtonNetClient.HttpsClient.
|
protectedvirtual |
Processes the response header received from the server.
response | The HTTP response received. |
Reimplemented from XmobiTea.ProtonNetClient.HttpsClient.
|
virtual |
Handles a close frame received from the server.
buffer | The buffer containing the close frame. |
position | The starting position in the buffer. |
length | The length of the close frame. |
status | The close status code. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
|
virtual |
Called when the WebSocket connection is successfully established.
request | The HTTP request that initiated the WebSocket connection. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
|
virtual |
Called when the WebSocket connection is successfully established.
response | The HTTP response that confirms the WebSocket upgrade. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
Reimplemented in XmobiTea.ProtonNet.Client.Socket.Clients.SocketWssClient.
|
virtual |
Prepares the WebSocket connection by setting the necessary headers.
request | The HTTP request being sent to initiate the WebSocket connection. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
|
virtual |
OnWsConnecting.
request | The HTTP request that initiated the WebSocket connection. |
response | The HTTP response that initiated the WebSocket connection. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
|
virtual |
Called when the WebSocket connection is successfully disconnected.
Implements XmobiTea.ProtonNetCommon.IWebSocket.
|
virtual |
Called when the WebSocket connection is in the process of disconnecting.
Implements XmobiTea.ProtonNetCommon.IWebSocket.
|
virtual |
Handles a WebSocket error by reporting it to the client.
error | The socket error. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
|
virtual |
Handles a WebSocket error by reporting it to the client.
error | The error message. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
|
virtual |
Handles a ping frame received from the server by sending a pong frame.
buffer | The buffer containing the ping frame. |
position | The starting position in the buffer. |
length | The length of the ping frame. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
|
virtual |
Handles a pong frame received from the server.
buffer | The buffer containing the pong frame. |
position | The starting position in the buffer. |
length | The length of the pong frame. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
|
virtual |
Processes the WebSocket frames received from the server.
buffer | The buffer containing the received data. |
position | The starting position in the buffer. |
length | The length of the received data. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
Reimplemented in XmobiTea.ProtonNet.Client.Socket.Clients.SocketWssClient.
int XmobiTea.ProtonNetClient.WssClient.SendBinary | ( | byte[] | buffer | ) |
Sends a binary message synchronously to the server.
buffer | The byte array containing the binary message. |
Implements XmobiTea.ProtonNetClient.IWsClient.
int XmobiTea.ProtonNetClient.WssClient.SendBinary | ( | byte[] | buffer, |
int | position, | ||
int | length ) |
Sends a binary message synchronously to the server.
buffer | The byte array containing the binary message. |
position | The starting position in the buffer. |
length | The number of bytes to send. |
Implements XmobiTea.ProtonNetClient.IWsClient.
bool XmobiTea.ProtonNetClient.WssClient.SendBinaryAsync | ( | byte[] | buffer | ) |
Sends a binary message asynchronously to the server.
buffer | The byte array containing the binary message. |
Implements XmobiTea.ProtonNetClient.IWsClient.
bool XmobiTea.ProtonNetClient.WssClient.SendBinaryAsync | ( | byte[] | buffer, |
int | position, | ||
int | length ) |
Sends a binary message asynchronously to the server.
buffer | The byte array containing the binary message. |
position | The starting position in the buffer. |
length | The number of bytes to send. |
Implements XmobiTea.ProtonNetClient.IWsClient.
int XmobiTea.ProtonNetClient.WssClient.SendClose | ( | int | status, |
byte[] | buffer ) |
Sends a close frame with a status code synchronously to the server.
status | The close status code. |
buffer | The byte array containing the close message. |
Implements XmobiTea.ProtonNetClient.IWsClient.
int XmobiTea.ProtonNetClient.WssClient.SendClose | ( | int | status, |
byte[] | buffer, | ||
int | position, | ||
int | length ) |
Sends a close frame with a status code synchronously to the server.
status | The close status code. |
buffer | The byte array containing the close message. |
position | The starting position in the buffer. |
length | The number of bytes to send. |
Implements XmobiTea.ProtonNetClient.IWsClient.
bool XmobiTea.ProtonNetClient.WssClient.SendCloseAsync | ( | int | status, |
byte[] | buffer ) |
Sends a close frame with a status code asynchronously to the server.
status | The close status code. |
buffer | The byte array containing the close message. |
Implements XmobiTea.ProtonNetClient.IWsClient.
bool XmobiTea.ProtonNetClient.WssClient.SendCloseAsync | ( | int | status, |
byte[] | buffer, | ||
int | position, | ||
int | length ) |
Sends a close frame with a status code asynchronously to the server.
status | The close status code. |
buffer | The byte array containing the close message. |
position | The starting position in the buffer. |
length | The number of bytes to send. |
Implements XmobiTea.ProtonNetClient.IWsClient.
int XmobiTea.ProtonNetClient.WssClient.SendPing | ( | byte[] | buffer | ) |
Sends a ping frame synchronously to the server.
buffer | The byte array containing the ping message. |
Implements XmobiTea.ProtonNetClient.IWsClient.
int XmobiTea.ProtonNetClient.WssClient.SendPing | ( | byte[] | buffer, |
int | position, | ||
int | length ) |
Sends a ping frame synchronously to the server.
buffer | The byte array containing the ping message. |
position | The starting position in the buffer. |
length | The number of bytes to send. |
Implements XmobiTea.ProtonNetClient.IWsClient.
bool XmobiTea.ProtonNetClient.WssClient.SendPingAsync | ( | byte[] | buffer | ) |
Sends a ping frame asynchronously to the server.
buffer | The byte array containing the ping message. |
Implements XmobiTea.ProtonNetClient.IWsClient.
bool XmobiTea.ProtonNetClient.WssClient.SendPingAsync | ( | byte[] | buffer, |
int | position, | ||
int | length ) |
Sends a ping frame asynchronously to the server.
buffer | The byte array containing the ping message. |
position | The starting position in the buffer. |
length | The number of bytes to send. |
Implements XmobiTea.ProtonNetClient.IWsClient.
int XmobiTea.ProtonNetClient.WssClient.SendPong | ( | byte[] | buffer | ) |
Sends a pong frame synchronously to the server.
buffer | The byte array containing the pong message. |
Implements XmobiTea.ProtonNetClient.IWsClient.
int XmobiTea.ProtonNetClient.WssClient.SendPong | ( | byte[] | buffer, |
int | position, | ||
int | length ) |
Sends a pong frame synchronously to the server.
buffer | The byte array containing the pong message. |
position | The starting position in the buffer. |
length | The number of bytes to send. |
Implements XmobiTea.ProtonNetClient.IWsClient.
bool XmobiTea.ProtonNetClient.WssClient.SendPongAsync | ( | byte[] | buffer | ) |
Sends a pong frame asynchronously to the server.
buffer | The byte array containing the pong message. |
Implements XmobiTea.ProtonNetClient.IWsClient.
bool XmobiTea.ProtonNetClient.WssClient.SendPongAsync | ( | byte[] | buffer, |
int | position, | ||
int | length ) |
Sends a pong frame asynchronously to the server.
buffer | The byte array containing the pong message. |
position | The starting position in the buffer. |
length | The number of bytes to send. |
Implements XmobiTea.ProtonNetClient.IWsClient.
int XmobiTea.ProtonNetClient.WssClient.SendText | ( | byte[] | buffer | ) |
Sends a text message synchronously to the server.
buffer | The byte array containing the text message. |
Implements XmobiTea.ProtonNetClient.IWsClient.
int XmobiTea.ProtonNetClient.WssClient.SendText | ( | byte[] | buffer, |
int | position, | ||
int | length ) |
Sends a text message synchronously to the server.
buffer | The byte array containing the text message. |
position | The starting position in the buffer. |
length | The number of bytes to send. |
Implements XmobiTea.ProtonNetClient.IWsClient.
bool XmobiTea.ProtonNetClient.WssClient.SendTextAsync | ( | byte[] | buffer | ) |
Sends a text message asynchronously to the server.
buffer | The byte array containing the text message. |
Implements XmobiTea.ProtonNetClient.IWsClient.
bool XmobiTea.ProtonNetClient.WssClient.SendTextAsync | ( | byte[] | buffer, |
int | position, | ||
int | length ) |
Sends a text message asynchronously to the server.
buffer | The byte array containing the text message. |
position | The starting position in the buffer. |
length | The number of bytes to send. |
Implements XmobiTea.ProtonNetClient.IWsClient.
void XmobiTea.ProtonNetClient.WssClient.SendUpgrade | ( | HttpResponse | response | ) |
Upgrades the HTTP connection to a WebSocket connection.
response | The HTTP response confirming the upgrade. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.