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

Represents a secure WebSocket session that inherits from HttpsSession and implements WebSocket functionality. More...

Inheritance diagram for XmobiTea.ProtonNetServer.WssSession:
XmobiTea.ProtonNetServer.HttpsSession XmobiTea.ProtonNetCommon.IWebSocket XmobiTea.ProtonNetServer.IWsSession XmobiTea.ProtonNetServer.SslSession XmobiTea.ProtonNetServer.IHttpSession XmobiTea.ProtonNetServer.ISession XmobiTea.ProtonNetServer.ITcpSession XmobiTea.ProtonNetServer.ISession XmobiTea.ProtonNetServer.ISession XmobiTea.ProtonNet.Server.Socket.Sessions.SocketWssSession

Public Member Functions

WssSession(WssServer server) int SendText (byte[] buffer)
 Initializes a new instance of the WssSession class with the specified WebSocket server.
 
int SendText (byte[] buffer, int position, int length)
 Sends a text message synchronously to the WebSocket connection with a specified position and length.
 
bool SendTextAsync (byte[] buffer)
 Sends a text message asynchronously to the WebSocket connection.
 
bool SendTextAsync (byte[] buffer, int position, int length)
 Sends a text message asynchronously to the WebSocket connection with a specified position and length.
 
int SendBinary (byte[] buffer)
 Sends a binary message synchronously to the WebSocket connection.
 
int SendBinary (byte[] buffer, int position, int length)
 Sends a binary message synchronously to the WebSocket connection with a specified position and length.
 
bool SendBinaryAsync (byte[] buffer)
 Sends a binary message asynchronously to the WebSocket connection.
 
bool SendBinaryAsync (byte[] buffer, int position, int length)
 Sends a binary message asynchronously to the WebSocket connection with a specified position and length.
 
int SendClose (int status, byte[] buffer)
 Sends a close frame synchronously to the WebSocket connection with the specified status code and buffer.
 
int SendClose (int status, byte[] buffer, int position, int length)
 Sends a close frame synchronously to the WebSocket connection with the specified status code, buffer, position, and length.
 
bool SendCloseAsync (int status, byte[] buffer)
 Sends a close frame asynchronously to the WebSocket connection with the specified status code and buffer.
 
bool SendCloseAsync (int status, byte[] buffer, int position, int length)
 Sends a close frame asynchronously to the WebSocket connection with the specified status code, buffer, position, and length.
 
int SendPing (byte[] buffer)
 Sends a ping frame synchronously to the WebSocket connection.
 
int SendPing (byte[] buffer, int position, int length)
 Sends a ping frame synchronously to the WebSocket connection with a specified position and length.
 
bool SendPingAsync (byte[] buffer)
 Sends a ping frame asynchronously to the WebSocket connection.
 
bool SendPingAsync (byte[] buffer, int position, int length)
 Sends a ping frame asynchronously to the WebSocket connection with a specified position and length.
 
int SendPong (byte[] buffer)
 Sends a pong frame synchronously to the WebSocket connection.
 
int SendPong (byte[] buffer, int position, int length)
 Sends a pong frame synchronously to the WebSocket connection with a specified position and length.
 
bool SendPongAsync (byte[] buffer)
 Sends a pong frame asynchronously to the WebSocket connection.
 
bool SendPongAsync (byte[] buffer, int position, int length)
 Sends a pong frame asynchronously to the WebSocket connection with a specified position and length.
 
virtual void OnWsConnecting (HttpRequest request)
 Called when a WebSocket connection is being established.
 
virtual void OnWsConnected (HttpResponse response)
 Called when a WebSocket connection is successfully established.
 
virtual bool OnWsConnecting (HttpRequest request, HttpResponse response)
 Called when a WebSocket connection is being established.
 
virtual void OnWsConnected (HttpRequest request)
 Called when a WebSocket connection is successfully established.
 
virtual void OnWsDisconnecting ()
 Called when a WebSocket connection is being disconnected.
 
virtual void OnWsDisconnected ()
 Called when a WebSocket connection is successfully disconnected.
 
virtual void OnWsReceived (byte[] buffer, int position, int length)
 Called when data is received from the WebSocket connection.
 
virtual void OnWsClose (byte[] buffer, int position, int length, int status=1000)
 Called when a WebSocket connection is closed.
 
virtual void OnWsPing (byte[] buffer, int position, int length)
 Called when a WebSocket ping is received.
 
virtual void OnWsPong (byte[] buffer, int position, int length)
 Called when a WebSocket pong is received.
 
virtual void OnWsError (string error)
 Called when a WebSocket error occurs with a custom error message.
 
virtual void OnWsError (SocketError error)
 Called when a WebSocket error occurs with a SocketError instance.
 
void SendUpgrade (HttpResponse response)
 Sends a WebSocket upgrade response to the client.
 
- Public Member Functions inherited from XmobiTea.ProtonNetServer.HttpsSession
 HttpsSession (HttpsServer server)
 Initializes a new instance of the HttpsSession class.
 
virtual int SendResponse (HttpResponse response)
 Sends an HTTP response synchronously.
 
virtual bool SendResponseAsync (HttpResponse response)
 Sends an HTTP response asynchronously.
 
- Public Member Functions inherited from XmobiTea.ProtonNetServer.SslSession
 SslSession (SslServer server)
 Initializes a new instance of the SslSession class.
 
INetworkStatistics GetNetworkStatistics ()
 Gets the network statistics for this session.
 
virtual bool Disconnect ()
 Disconnects the session, releasing all resources and closing the connection.
 
virtual int Send (byte[] buffer)
 Sends data to the connected client.
 
virtual int Send (byte[] buffer, int position, int length)
 Sends data to the connected client.
 
virtual bool SendAsync (byte[] buffer)
 Asynchronously sends data to the connected client.
 
virtual bool SendAsync (byte[] buffer, int position, int length)
 Asynchronously sends data to the connected client.
 
void Dispose ()
 Releases all resources used by the SslSession.
 
- Public Member Functions inherited from XmobiTea.ProtonNetServer.ISession
- Public Member Functions inherited from XmobiTea.ProtonNetServer.IHttpSession
- Public Member Functions inherited from XmobiTea.ProtonNetCommon.IWebSocket
- Public Member Functions inherited from XmobiTea.ProtonNetServer.IWsSession

Protected Member Functions

override void OnDisconnecting ()
 Called when the session is disconnecting.
 
override void OnDisconnected ()
 Called when the session has been disconnected.
 
override void OnReceived (byte[] buffer, int position, int length)
 Called when data is received from the connection.
 
override void OnReceivedRequestHeader (HttpRequest request)
 Called when the HTTP request headers are received.
 
override void OnReceivedRequest (HttpRequest request)
 Called when the complete HTTP request is received.
 
override void OnReceivedRequestError (HttpRequest request, string error)
 Called when an error occurs while receiving the HTTP request.
 
- Protected Member Functions inherited from XmobiTea.ProtonNetServer.HttpsSession
- Protected Member Functions inherited from XmobiTea.ProtonNetServer.SslSession
virtual void OnConnecting ()
 Event triggered when the session is connecting.
 
virtual void OnConnected ()
 Event triggered when the session is connected.
 
virtual void OnHandshaking ()
 Event triggered when the SSL handshake process begins.
 
virtual void OnHandshaked ()
 Event triggered when the SSL handshake process is completed.
 
virtual void OnSent (int sent, int pending)
 Event triggered when data is sent to the client.
 
virtual void OnEmpty ()
 Event triggered when the send buffer is empty.
 
virtual void OnError (SocketError error)
 Event triggered when an error occurs in the session.
 
virtual void Dispose (bool disposingManagedResources)
 Releases unmanaged and, optionally, managed resources.
 

Additional Inherited Members

- Package Functions inherited from XmobiTea.ProtonNetServer.SslSession
- Properties inherited from XmobiTea.ProtonNetServer.HttpsSession
HttpRequest Request [get]
 Gets the current HTTP request being processed.
 
HttpResponse Response [get]
 Gets the current HTTP response being processed.
 
- Properties inherited from XmobiTea.ProtonNetServer.SslSession
bool IsHandshaked [get]
 Gets a value indicating whether the session has completed the SSL handshake.
 
string Id [get]
 Gets the unique identifier for this session.
 
SslServer Server [get]
 Gets the associated server instance for this session.
 
Socket Socket [get]
 Gets the underlying socket for the session.
 
bool IsConnected [get]
 Gets a value indicating whether the session is currently connected.
 
bool IsDisposed [get]
 Indicates whether this session has been disposed. This flag helps ensure that resources are not accessed after disposal.
 
bool IsSocketDisposed [get]
 Indicates whether the underlying socket has been disposed. This flag is important for preventing operations on a closed socket.
 
TcpServerOptions Options [get]
 Contains various configuration options for the TCP server. This includes settings like buffer sizes, keep-alive time, and more.
 

Detailed Description

Represents a secure WebSocket session that inherits from HttpsSession and implements WebSocket functionality.

Member Function Documentation

◆ OnDisconnected()

override void XmobiTea.ProtonNetServer.WssSession.OnDisconnected ( )
protectedvirtual

Called when the session has been disconnected.

Reimplemented from XmobiTea.ProtonNetServer.HttpsSession.

◆ OnDisconnecting()

override void XmobiTea.ProtonNetServer.WssSession.OnDisconnecting ( )
protectedvirtual

Called when the session is disconnecting.

Reimplemented from XmobiTea.ProtonNetServer.SslSession.

◆ OnReceived()

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

Called when data is received from the connection.

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

Reimplemented from XmobiTea.ProtonNetServer.HttpsSession.

◆ OnReceivedRequest()

override void XmobiTea.ProtonNetServer.WssSession.OnReceivedRequest ( HttpRequest request)
protectedvirtual

Called when the complete HTTP request is received.

Parameters
requestThe received HTTP request.

Reimplemented from XmobiTea.ProtonNetServer.HttpsSession.

◆ OnReceivedRequestError()

override void XmobiTea.ProtonNetServer.WssSession.OnReceivedRequestError ( HttpRequest request,
string error )
protectedvirtual

Called when an error occurs while receiving the HTTP request.

Parameters
requestThe HTTP request that caused the error.
errorThe error message.

Reimplemented from XmobiTea.ProtonNetServer.HttpsSession.

◆ OnReceivedRequestHeader()

override void XmobiTea.ProtonNetServer.WssSession.OnReceivedRequestHeader ( HttpRequest request)
protectedvirtual

Called when the HTTP request headers are received.

Parameters
requestThe HTTP request containing the headers.

Reimplemented from XmobiTea.ProtonNetServer.HttpsSession.

◆ OnWsClose()

virtual void XmobiTea.ProtonNetServer.WssSession.OnWsClose ( byte[] buffer,
int position,
int length,
int status = 1000 )
virtual

Called when a WebSocket connection is closed.

Parameters
bufferThe close data buffer.
positionThe starting position in the buffer.
lengthThe length of the close data.
statusThe close status code.

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsConnected() [1/2]

virtual void XmobiTea.ProtonNetServer.WssSession.OnWsConnected ( HttpRequest request)
virtual

Called when a WebSocket connection is successfully established.

Parameters
requestThe HTTP request for the WebSocket connection.

Implements XmobiTea.ProtonNetCommon.IWebSocket.

Reimplemented in XmobiTea.ProtonNet.Server.Socket.Sessions.SocketWssSession.

◆ OnWsConnected() [2/2]

virtual void XmobiTea.ProtonNetServer.WssSession.OnWsConnected ( HttpResponse response)
virtual

Called when a WebSocket connection is successfully established.

Parameters
responseThe HTTP response for the WebSocket connection.

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsConnecting() [1/2]

virtual void XmobiTea.ProtonNetServer.WssSession.OnWsConnecting ( HttpRequest request)
virtual

Called when a WebSocket connection is being established.

Parameters
requestThe HTTP request for the WebSocket connection.

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsConnecting() [2/2]

virtual bool XmobiTea.ProtonNetServer.WssSession.OnWsConnecting ( HttpRequest request,
HttpResponse response )
virtual

Called when a WebSocket connection is being established.

Parameters
requestThe HTTP request for the WebSocket connection.
responseThe HTTP response for the WebSocket connection.
Returns
True if the connection is allowed; otherwise, false.

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsDisconnected()

virtual void XmobiTea.ProtonNetServer.WssSession.OnWsDisconnected ( )
virtual

Called when a WebSocket connection is successfully disconnected.

Implements XmobiTea.ProtonNetCommon.IWebSocket.

Reimplemented in XmobiTea.ProtonNet.Server.Socket.Sessions.SocketWssSession.

◆ OnWsDisconnecting()

virtual void XmobiTea.ProtonNetServer.WssSession.OnWsDisconnecting ( )
virtual

Called when a WebSocket connection is being disconnected.

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsError() [1/2]

virtual void XmobiTea.ProtonNetServer.WssSession.OnWsError ( SocketError error)
virtual

Called when a WebSocket error occurs with a SocketError instance.

Parameters
errorThe SocketError that occurred.

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsError() [2/2]

virtual void XmobiTea.ProtonNetServer.WssSession.OnWsError ( string error)
virtual

Called when a WebSocket error occurs with a custom error message.

Parameters
errorThe error message.

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsPing()

virtual void XmobiTea.ProtonNetServer.WssSession.OnWsPing ( byte[] buffer,
int position,
int length )
virtual

Called when a WebSocket ping is received.

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

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsPong()

virtual void XmobiTea.ProtonNetServer.WssSession.OnWsPong ( byte[] buffer,
int position,
int length )
virtual

Called when a WebSocket pong is received.

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

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsReceived()

virtual void XmobiTea.ProtonNetServer.WssSession.OnWsReceived ( byte[] buffer,
int position,
int length )
virtual

Called when data is received from the WebSocket connection.

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

Implements XmobiTea.ProtonNetCommon.IWebSocket.

Reimplemented in XmobiTea.ProtonNet.Server.Socket.Sessions.SocketWssSession.

◆ SendBinary() [1/2]

int XmobiTea.ProtonNetServer.WssSession.SendBinary ( byte[] buffer)

Sends a binary message synchronously to the WebSocket connection.

Parameters
bufferThe buffer containing the binary message.
Returns
The number of bytes sent.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendBinary() [2/2]

int XmobiTea.ProtonNetServer.WssSession.SendBinary ( byte[] buffer,
int position,
int length )

Sends a binary message synchronously to the WebSocket connection with a specified position and length.

Parameters
bufferThe buffer containing the binary message.
positionThe starting position in the buffer.
lengthThe length of the data to send.
Returns
The number of bytes sent.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendBinaryAsync() [1/2]

bool XmobiTea.ProtonNetServer.WssSession.SendBinaryAsync ( byte[] buffer)

Sends a binary message asynchronously to the WebSocket connection.

Parameters
bufferThe buffer containing the binary message.
Returns
True if the message was sent successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendBinaryAsync() [2/2]

bool XmobiTea.ProtonNetServer.WssSession.SendBinaryAsync ( byte[] buffer,
int position,
int length )

Sends a binary message asynchronously to the WebSocket connection with a specified position and length.

Parameters
bufferThe buffer containing the binary message.
positionThe starting position in the buffer.
lengthThe length of the data to send.
Returns
True if the message was sent successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendClose() [1/2]

int XmobiTea.ProtonNetServer.WssSession.SendClose ( int status,
byte[] buffer )

Sends a close frame synchronously to the WebSocket connection with the specified status code and buffer.

Parameters
statusThe close status code.
bufferThe buffer containing additional data to send with the close frame.
Returns
The number of bytes sent.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendClose() [2/2]

int XmobiTea.ProtonNetServer.WssSession.SendClose ( int status,
byte[] buffer,
int position,
int length )

Sends a close frame synchronously to the WebSocket connection with the specified status code, buffer, position, and length.

Parameters
statusThe close status code.
bufferThe buffer containing additional data to send with the close frame.
positionThe starting position in the buffer.
lengthThe length of the data to send.
Returns
The number of bytes sent.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendCloseAsync() [1/2]

bool XmobiTea.ProtonNetServer.WssSession.SendCloseAsync ( int status,
byte[] buffer )

Sends a close frame asynchronously to the WebSocket connection with the specified status code and buffer.

Parameters
statusThe close status code.
bufferThe buffer containing additional data to send with the close frame.
Returns
True if the close frame was sent successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendCloseAsync() [2/2]

bool XmobiTea.ProtonNetServer.WssSession.SendCloseAsync ( int status,
byte[] buffer,
int position,
int length )

Sends a close frame asynchronously to the WebSocket connection with the specified status code, buffer, position, and length.

Parameters
statusThe close status code.
bufferThe buffer containing additional data to send with the close frame.
positionThe starting position in the buffer.
lengthThe length of the data to send.
Returns
True if the close frame was sent successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendPing() [1/2]

int XmobiTea.ProtonNetServer.WssSession.SendPing ( byte[] buffer)

Sends a ping frame synchronously to the WebSocket connection.

Parameters
bufferThe buffer containing the ping frame.
Returns
The number of bytes sent.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendPing() [2/2]

int XmobiTea.ProtonNetServer.WssSession.SendPing ( byte[] buffer,
int position,
int length )

Sends a ping frame synchronously to the WebSocket connection with a specified position and length.

Parameters
bufferThe buffer containing the ping frame.
positionThe starting position in the buffer.
lengthThe length of the data to send.
Returns
The number of bytes sent.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendPingAsync() [1/2]

bool XmobiTea.ProtonNetServer.WssSession.SendPingAsync ( byte[] buffer)

Sends a ping frame asynchronously to the WebSocket connection.

Parameters
bufferThe buffer containing the ping frame.
Returns
True if the ping frame was sent successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendPingAsync() [2/2]

bool XmobiTea.ProtonNetServer.WssSession.SendPingAsync ( byte[] buffer,
int position,
int length )

Sends a ping frame asynchronously to the WebSocket connection with a specified position and length.

Parameters
bufferThe buffer containing the ping frame.
positionThe starting position in the buffer.
lengthThe length of the data to send.
Returns
True if the ping frame was sent successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendPong() [1/2]

int XmobiTea.ProtonNetServer.WssSession.SendPong ( byte[] buffer)

Sends a pong frame synchronously to the WebSocket connection.

Parameters
bufferThe buffer containing the pong frame.
Returns
The number of bytes sent.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendPong() [2/2]

int XmobiTea.ProtonNetServer.WssSession.SendPong ( byte[] buffer,
int position,
int length )

Sends a pong frame synchronously to the WebSocket connection with a specified position and length.

Parameters
bufferThe buffer containing the pong frame.
positionThe starting position in the buffer.
lengthThe length of the data to send.
Returns
The number of bytes sent.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendPongAsync() [1/2]

bool XmobiTea.ProtonNetServer.WssSession.SendPongAsync ( byte[] buffer)

Sends a pong frame asynchronously to the WebSocket connection.

Parameters
bufferThe buffer containing the pong frame.
Returns
True if the pong frame was sent successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendPongAsync() [2/2]

bool XmobiTea.ProtonNetServer.WssSession.SendPongAsync ( byte[] buffer,
int position,
int length )

Sends a pong frame asynchronously to the WebSocket connection with a specified position and length.

Parameters
bufferThe buffer containing the pong frame.
positionThe starting position in the buffer.
lengthThe length of the data to send.
Returns
True if the pong frame was sent successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendText() [1/2]

WssSession(WssServer server) int XmobiTea.ProtonNetServer.WssSession.SendText ( byte[] buffer)

Initializes a new instance of the WssSession class with the specified WebSocket server.

Parameters
serverThe WebSocket server.

Sends a text message synchronously to the WebSocket connection.

Parameters
bufferThe buffer containing the text message.
Returns
The number of bytes sent.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendText() [2/2]

int XmobiTea.ProtonNetServer.WssSession.SendText ( byte[] buffer,
int position,
int length )

Sends a text message synchronously to the WebSocket connection with a specified position and length.

Parameters
bufferThe buffer containing the text message.
positionThe starting position in the buffer.
lengthThe length of the data to send.
Returns
The number of bytes sent.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendTextAsync() [1/2]

bool XmobiTea.ProtonNetServer.WssSession.SendTextAsync ( byte[] buffer)

Sends a text message asynchronously to the WebSocket connection.

Parameters
bufferThe buffer containing the text message.
Returns
True if the message was sent successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendTextAsync() [2/2]

bool XmobiTea.ProtonNetServer.WssSession.SendTextAsync ( byte[] buffer,
int position,
int length )

Sends a text message asynchronously to the WebSocket connection with a specified position and length.

Parameters
bufferThe buffer containing the text message.
positionThe starting position in the buffer.
lengthThe length of the data to send.
Returns
True if the message was sent successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsSession.

◆ SendUpgrade()

void XmobiTea.ProtonNetServer.WssSession.SendUpgrade ( HttpResponse response)

Sends a WebSocket upgrade response to the client.

Parameters
responseThe HTTP response containing the WebSocket upgrade information.

Implements XmobiTea.ProtonNetCommon.IWebSocket.


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