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

Represents a secure WebSocket server that inherits from HttpsServer and implements WebSocket functionality. More...

Inheritance diagram for XmobiTea.ProtonNetServer.WssServer:
XmobiTea.ProtonNetServer.HttpsServer XmobiTea.ProtonNetCommon.IWebSocket XmobiTea.ProtonNetServer.IWsServer XmobiTea.ProtonNetServer.SslServer XmobiTea.ProtonNetServer.IHttpServer XmobiTea.ProtonNetServer.IServer XmobiTea.ProtonNetServer.ITcpServer XmobiTea.ProtonNetServer.IServer XmobiTea.ProtonNetServer.IServer XmobiTea.ProtonNet.Server.Socket.Server.SocketWssServer

Public Member Functions

virtual bool CloseAll ()
 Closes all WebSocket sessions with a default status code of 0.
 
virtual bool CloseAll (int status)
 Closes all WebSocket sessions with the specified status code.
 
virtual bool CloseAll (int status, byte[] buffer)
 Closes all WebSocket sessions with the specified status code and an additional buffer.
 
virtual bool CloseAll (int status, byte[] buffer, int position, int length)
 Closes all WebSocket sessions with the specified status code, buffer, and position/length parameters.
 
override bool BroadcastAll (byte[] buffer)
 Broadcasts a message to all connected WebSocket sessions.
 
override bool BroadcastAll (byte[] buffer, int position, int length)
 Broadcasts a message to all connected WebSocket sessions with a specified position and length.
 
override bool BroadcastAllAsync (byte[] buffer)
 Asynchronously broadcasts a message to all connected WebSocket sessions.
 
override bool BroadcastAllAsync (byte[] buffer, int position, int length)
 Asynchronously broadcasts a message to all connected WebSocket sessions with a specified position and length.
 
bool MulticastText (byte[] buffer)
 Sends a text message to all connected WebSocket sessions.
 
bool MulticastText (byte[] buffer, int position, int size)
 Sends a text message to all connected WebSocket sessions with a specified position and length.
 
bool MulticastTextAsync (byte[] buffer)
 Asynchronously sends a text message to all connected WebSocket sessions.
 
bool MulticastTextAsync (byte[] buffer, int position, int size)
 Asynchronously sends a text message to all connected WebSocket sessions with a specified position and length.
 
bool MulticastBinary (byte[] buffer)
 Sends a binary message to all connected WebSocket sessions.
 
bool MulticastBinary (byte[] buffer, int position, int size)
 Sends a binary message to all connected WebSocket sessions with a specified position and length.
 
bool MulticastBinaryAsync (byte[] buffer)
 Asynchronously sends a binary message to all connected WebSocket sessions.
 
bool MulticastBinaryAsync (byte[] buffer, int position, int size)
 Asynchronously sends a binary message to all connected WebSocket sessions with a specified position and length.
 
bool MulticastPing (byte[] buffer)
 Sends a ping message to all connected WebSocket sessions.
 
bool MulticastPing (byte[] buffer, int position, int size)
 Sends a ping message to all connected WebSocket sessions with a specified position and length.
 
bool MulticastPingAsync (byte[] buffer)
 Asynchronously sends a ping message to all connected WebSocket sessions.
 
bool MulticastPingAsync (byte[] buffer, int position, int size)
 Asynchronously sends a ping message to all connected WebSocket sessions with a specified position and length.
 
void OnWsConnecting (HttpRequest request)
 Called when a WebSocket connection is being established. Override this method to add custom logic during WebSocket connection.
 
void OnWsConnected (HttpResponse response)
 Called when a WebSocket connection is successfully established. Override this method to add custom logic after WebSocket connection.
 
bool OnWsConnecting (HttpRequest request, HttpResponse response)
 Called when a WebSocket connection is being established. Override this method to add custom logic during WebSocket connection.
 
void OnWsConnected (HttpRequest request)
 Called when a WebSocket connection is successfully established. Override this method to add custom logic after WebSocket connection.
 
void OnWsDisconnecting ()
 Called when a WebSocket connection is being disconnected. Override this method to add custom logic during WebSocket disconnection.
 
void OnWsDisconnected ()
 Called when a WebSocket connection is successfully disconnected. Override this method to add custom logic after WebSocket disconnection.
 
void OnWsReceived (byte[] buffer, int position, int length)
 Called when data is received from the WebSocket connection. Override this method to process received data.
 
void OnWsClose (byte[] buffer, int position, int length, int status=1000)
 Called when a WebSocket connection is closed. Override this method to handle WebSocket close events.
 
void OnWsPing (byte[] buffer, int position, int length)
 Called when a WebSocket ping is received. Override this method to handle WebSocket ping events.
 
void OnWsPong (byte[] buffer, int position, int length)
 Called when a WebSocket pong is received. Override this method to handle WebSocket pong events.
 
void OnWsError (string error)
 Called when a WebSocket error occurs. Override this method to handle WebSocket errors with a custom message.
 
void OnWsError (SocketError error)
 Called when a WebSocket error occurs. Override this method to handle WebSocket errors with a SocketError instance.
 
void SendUpgrade (HttpResponse response)
 Sends a WebSocket upgrade response to the client.
 
- Public Member Functions inherited from XmobiTea.ProtonNetServer.HttpsServer
 HttpsServer (string address, int port, TcpServerOptions options, SslOptions sslOptions)
 Initializes a new instance of the HttpsServer class.
 
- Public Member Functions inherited from XmobiTea.ProtonNetServer.SslServer
 SslServer (string address, int port, TcpServerOptions options, SslOptions sslOptions)
 Initializes a new instance of the SslServer class with the specified address, port, options, and Ssl options.
 
virtual bool Start ()
 Starts the SSL server.
 
virtual bool Stop ()
 Stops the SSL server.
 
virtual bool Restart ()
 Restarts the SSL server.
 
virtual bool DisconnectAll ()
 Disconnects all connected secure sessions.
 
IServerNetworkStatistics GetNetworkStatistics ()
 Gets the network statistics for the server.
 
SslSession GetSession (string id)
 Finds a secure session by its identifier.
 
void Dispose ()
 Disposes the server and its resources.
 
- Public Member Functions inherited from XmobiTea.ProtonNetServer.IServer
- Public Member Functions inherited from XmobiTea.ProtonNetCommon.IWebSocket
- Public Member Functions inherited from XmobiTea.ProtonNetServer.IWsServer

Protected Member Functions

WssServer(string address, int port, TcpServerOptions options, SslOptions sslOptions) override SslSession CreateSession ()
 Initializes a new instance of the WssServer class with the specified address, port, options, and Ssl options.
 
- Protected Member Functions inherited from XmobiTea.ProtonNetServer.HttpsServer
- Protected Member Functions inherited from XmobiTea.ProtonNetServer.SslServer
virtual string CreateRandomId ()
 Creates a random identifier for the server.
 
virtual void OnStarting ()
 Called when the server is starting. Override this method to add custom logic during server startup.
 
virtual void OnStarted ()
 Called after the server has started successfully. Override this method to add custom logic after server startup.
 
virtual void OnStopping ()
 Called when the server is stopping. Override this method to add custom logic during server shutdown.
 
virtual void OnStopped ()
 Called after the server has stopped successfully. Override this method to add custom logic after server shutdown.
 
virtual void OnConnecting (SslSession session)
 Called when a session is connecting. Override this method to handle session-specific logic during the connection process.
 
virtual void OnConnected (SslSession session)
 Called after a session has connected successfully. Override this method to handle session-specific logic after the connection process.
 
virtual void OnHandshaking (SslSession session)
 Called when a session is undergoing the SSL/TLS handshake process. Override this method to handle session-specific logic during the handshake process.
 
virtual void OnHandshaked (SslSession session)
 Called after a session has successfully completed the SSL/TLS handshake. Override this method to handle session-specific logic after the handshake process.
 
virtual void OnDisconnecting (SslSession session)
 Called when a session is disconnecting. Override this method to handle session-specific logic during the disconnection process.
 
virtual void OnDisconnected (SslSession session)
 Called after a session has disconnected successfully. Override this method to handle session-specific logic after the disconnection process.
 
virtual void OnError (SocketError error)
 Called when a socket error occurs. Override this method to handle errors in a custom way.
 
virtual void Dispose (bool disposingManagedResources)
 Disposes the server, optionally releasing managed resources.
 

Additional Inherited Members

- Package Functions inherited from XmobiTea.ProtonNetServer.SslServer
- Properties inherited from XmobiTea.ProtonNetServer.SslServer
string Id [get]
 Gets the unique identifier for the server instance.
 
SslOptions SslOptions [get]
 Gets the Ssl options for secure communication.
 
string Address [get]
 Gets the server's IP address.
 
int Port [get]
 Gets the server's port number.
 
EndPoint EndPoint [get]
 Gets the server's endpoint.
 
ConcurrentDictionary< string, SslSessionSessions [get]
 Gets the collection of active secure sessions.
 
int ConnectedSessions [get]
 Gets the number of connected secure sessions.
 
TcpServerOptions Options [get]
 Gets the TCP server options.
 
bool IsStarted [get]
 Gets a value indicating whether the server is started.
 
bool IsAccepting [get]
 Gets a value indicating whether the server is currently accepting connections.
 
bool IsDisposed [get]
 Gets a value indicating whether the server is disposed.
 
bool IsSocketDisposed [get]
 Gets a value indicating whether the server socket is disposed.
 

Detailed Description

Represents a secure WebSocket server that inherits from HttpsServer and implements WebSocket functionality.

Member Function Documentation

◆ BroadcastAll() [1/2]

override bool XmobiTea.ProtonNetServer.WssServer.BroadcastAll ( byte[] buffer)
virtual

Broadcasts a message to all connected WebSocket sessions.

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

Reimplemented from XmobiTea.ProtonNetServer.SslServer.

◆ BroadcastAll() [2/2]

override bool XmobiTea.ProtonNetServer.WssServer.BroadcastAll ( byte[] buffer,
int position,
int length )
virtual

Broadcasts a message to all connected WebSocket sessions with a specified position and length.

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

Reimplemented from XmobiTea.ProtonNetServer.SslServer.

◆ BroadcastAllAsync() [1/2]

override bool XmobiTea.ProtonNetServer.WssServer.BroadcastAllAsync ( byte[] buffer)
virtual

Asynchronously broadcasts a message to all connected WebSocket sessions.

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

Reimplemented from XmobiTea.ProtonNetServer.SslServer.

◆ BroadcastAllAsync() [2/2]

override bool XmobiTea.ProtonNetServer.WssServer.BroadcastAllAsync ( byte[] buffer,
int position,
int length )
virtual

Asynchronously broadcasts a message to all connected WebSocket sessions with a specified position and length.

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

Reimplemented from XmobiTea.ProtonNetServer.SslServer.

◆ CloseAll() [1/4]

virtual bool XmobiTea.ProtonNetServer.WssServer.CloseAll ( )
virtual

Closes all WebSocket sessions with a default status code of 0.

Returns
True if all sessions were closed successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsServer.

◆ CloseAll() [2/4]

virtual bool XmobiTea.ProtonNetServer.WssServer.CloseAll ( int status)
virtual

Closes all WebSocket sessions with the specified status code.

Parameters
statusThe status code to use when closing the sessions.
Returns
True if all sessions were closed successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsServer.

◆ CloseAll() [3/4]

virtual bool XmobiTea.ProtonNetServer.WssServer.CloseAll ( int status,
byte[] buffer )
virtual

Closes all WebSocket sessions with the specified status code and an additional buffer.

Parameters
statusThe status code to use when closing the sessions.
bufferThe buffer containing additional data to send before closing the sessions.
Returns
True if all sessions were closed successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsServer.

◆ CloseAll() [4/4]

virtual bool XmobiTea.ProtonNetServer.WssServer.CloseAll ( int status,
byte[] buffer,
int position,
int length )
virtual

Closes all WebSocket sessions with the specified status code, buffer, and position/length parameters.

Parameters
statusThe status code to use when closing the sessions.
bufferThe buffer containing additional data to send before closing the sessions.
positionThe starting position in the buffer.
lengthThe length of the data to send.
Returns
True if all sessions were closed successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsServer.

◆ CreateSession()

WssServer(string address, int port, TcpServerOptions options, SslOptions sslOptions) override SslSession XmobiTea.ProtonNetServer.WssServer.CreateSession ( )
protectedvirtual

Initializes a new instance of the WssServer class with the specified address, port, options, and Ssl options.

Parameters
addressThe server's IP address.
portThe server's port number.
optionsThe TCP server options.
sslOptionsThe Ssl options for secure communication.

Creates a new secure WebSocket session.

Returns
A new instance of WssSession.

Reimplemented from XmobiTea.ProtonNetServer.HttpsServer.

◆ MulticastBinary() [1/2]

bool XmobiTea.ProtonNetServer.WssServer.MulticastBinary ( byte[] buffer)

Sends a binary message to all connected WebSocket sessions.

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

Implements XmobiTea.ProtonNetServer.IWsServer.

◆ MulticastBinary() [2/2]

bool XmobiTea.ProtonNetServer.WssServer.MulticastBinary ( byte[] buffer,
int position,
int size )

Sends a binary message to all connected WebSocket sessions with a specified position and length.

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

Implements XmobiTea.ProtonNetServer.IWsServer.

◆ MulticastBinaryAsync() [1/2]

bool XmobiTea.ProtonNetServer.WssServer.MulticastBinaryAsync ( byte[] buffer)

Asynchronously sends a binary message to all connected WebSocket sessions.

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

Implements XmobiTea.ProtonNetServer.IWsServer.

◆ MulticastBinaryAsync() [2/2]

bool XmobiTea.ProtonNetServer.WssServer.MulticastBinaryAsync ( byte[] buffer,
int position,
int size )

Asynchronously sends a binary message to all connected WebSocket sessions with a specified position and length.

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

Implements XmobiTea.ProtonNetServer.IWsServer.

◆ MulticastPing() [1/2]

bool XmobiTea.ProtonNetServer.WssServer.MulticastPing ( byte[] buffer)

Sends a ping message to all connected WebSocket sessions.

Parameters
bufferThe buffer containing the ping message to multicast.
Returns
True if the message was multicast successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsServer.

◆ MulticastPing() [2/2]

bool XmobiTea.ProtonNetServer.WssServer.MulticastPing ( byte[] buffer,
int position,
int size )

Sends a ping message to all connected WebSocket sessions with a specified position and length.

Parameters
bufferThe buffer containing the ping message to multicast.
positionThe starting position in the buffer.
sizeThe length of the data to multicast.
Returns
True if the message was multicast successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsServer.

◆ MulticastPingAsync() [1/2]

bool XmobiTea.ProtonNetServer.WssServer.MulticastPingAsync ( byte[] buffer)

Asynchronously sends a ping message to all connected WebSocket sessions.

Parameters
bufferThe buffer containing the ping message to multicast.
Returns
True if the message was multicast successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsServer.

◆ MulticastPingAsync() [2/2]

bool XmobiTea.ProtonNetServer.WssServer.MulticastPingAsync ( byte[] buffer,
int position,
int size )

Asynchronously sends a ping message to all connected WebSocket sessions with a specified position and length.

Parameters
bufferThe buffer containing the ping message to multicast.
positionThe starting position in the buffer.
sizeThe length of the data to multicast.
Returns
True if the message was multicast successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.IWsServer.

◆ MulticastText() [1/2]

bool XmobiTea.ProtonNetServer.WssServer.MulticastText ( byte[] buffer)

Sends a text message to all connected WebSocket sessions.

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

Implements XmobiTea.ProtonNetServer.IWsServer.

◆ MulticastText() [2/2]

bool XmobiTea.ProtonNetServer.WssServer.MulticastText ( byte[] buffer,
int position,
int size )

Sends a text message to all connected WebSocket sessions with a specified position and length.

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

Implements XmobiTea.ProtonNetServer.IWsServer.

◆ MulticastTextAsync() [1/2]

bool XmobiTea.ProtonNetServer.WssServer.MulticastTextAsync ( byte[] buffer)

Asynchronously sends a text message to all connected WebSocket sessions.

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

Implements XmobiTea.ProtonNetServer.IWsServer.

◆ MulticastTextAsync() [2/2]

bool XmobiTea.ProtonNetServer.WssServer.MulticastTextAsync ( byte[] buffer,
int position,
int size )

Asynchronously sends a text message to all connected WebSocket sessions with a specified position and length.

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

Implements XmobiTea.ProtonNetServer.IWsServer.

◆ OnWsClose()

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

Called when a WebSocket connection is closed. Override this method to handle WebSocket close events.

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]

void XmobiTea.ProtonNetServer.WssServer.OnWsConnected ( HttpRequest request)

Called when a WebSocket connection is successfully established. Override this method to add custom logic after WebSocket connection.

Parameters
requestThe HTTP request for the WebSocket connection.

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsConnected() [2/2]

void XmobiTea.ProtonNetServer.WssServer.OnWsConnected ( HttpResponse response)

Called when a WebSocket connection is successfully established. Override this method to add custom logic after WebSocket connection.

Parameters
responseThe HTTP response for the WebSocket connection.

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsConnecting() [1/2]

void XmobiTea.ProtonNetServer.WssServer.OnWsConnecting ( HttpRequest request)

Called when a WebSocket connection is being established. Override this method to add custom logic during WebSocket connection.

Parameters
requestThe HTTP request for the WebSocket connection.

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsConnecting() [2/2]

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

Called when a WebSocket connection is being established. Override this method to add custom logic during WebSocket connection.

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()

void XmobiTea.ProtonNetServer.WssServer.OnWsDisconnected ( )

Called when a WebSocket connection is successfully disconnected. Override this method to add custom logic after WebSocket disconnection.

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsDisconnecting()

void XmobiTea.ProtonNetServer.WssServer.OnWsDisconnecting ( )

Called when a WebSocket connection is being disconnected. Override this method to add custom logic during WebSocket disconnection.

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsError() [1/2]

void XmobiTea.ProtonNetServer.WssServer.OnWsError ( SocketError error)

Called when a WebSocket error occurs. Override this method to handle WebSocket errors with a SocketError instance.

Parameters
errorThe SocketError that occurred.

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsError() [2/2]

void XmobiTea.ProtonNetServer.WssServer.OnWsError ( string error)

Called when a WebSocket error occurs. Override this method to handle WebSocket errors with a custom message.

Parameters
errorThe error message.

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsPing()

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

Called when a WebSocket ping is received. Override this method to handle WebSocket ping events.

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

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsPong()

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

Called when a WebSocket pong is received. Override this method to handle WebSocket pong events.

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

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ OnWsReceived()

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

Called when data is received from the WebSocket connection. Override this method to process received data.

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

Implements XmobiTea.ProtonNetCommon.IWebSocket.

◆ SendUpgrade()

void XmobiTea.ProtonNetServer.WssServer.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: