|
ProtonNet Server 1.0
An Open Solution for all your socket or web api needs.
|
Represents a WebSocket server that inherits from HttpServer and implements WebSocket functionality. More...
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 offset, int size) |
| Closes all WebSocket sessions with the specified status code, buffer, and offset/size 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 length) |
| 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 length) |
| 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 length) |
| 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 length) |
| 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 length) |
| 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 length) |
| 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.HttpServer | |
| HttpServer (string address, int port, TcpServerOptions options) | |
| Initializes a new instance of the HttpServer class. | |
Public Member Functions inherited from XmobiTea.ProtonNetServer.TcpServer | |
| TcpServer (string address, int port, TcpServerOptions options) | |
| Initializes a new instance of the TcpServer class with the specified address, port, and options. | |
| virtual bool | Start () |
| Starts the TCP server. | |
| virtual bool | Stop () |
| Stops the TCP server. | |
| virtual bool | Restart () |
| Restarts the TCP server. | |
| virtual bool | DisconnectAll () |
| Disconnects all connected sessions. | |
| IServerNetworkStatistics | GetNetworkStatistics () |
| Gets the network statistics for the server. | |
| TcpSession | GetSession (string id) |
| Finds a 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 | |
| WsServer(string address, int port, TcpServerOptions options) override TcpSession | CreateSession () |
| Initializes a new instance of the WsServer class with the specified address, port, and options. | |
Protected Member Functions inherited from XmobiTea.ProtonNetServer.HttpServer | |
Protected Member Functions inherited from XmobiTea.ProtonNetServer.TcpServer | |
| 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 (TcpSession session) |
| Called when a session is connecting. Override this method to handle session-specific logic during the connection process. | |
| virtual void | OnConnected (TcpSession session) |
| Called after a session has connected successfully. Override this method to handle session-specific logic after the connection process. | |
| virtual void | OnDisconnecting (TcpSession session) |
| Called when a session is disconnecting. Override this method to handle session-specific logic during the disconnection process. | |
| virtual void | OnDisconnected (TcpSession 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.TcpServer | |
Properties inherited from XmobiTea.ProtonNetServer.TcpServer | |
| string | Id [get] |
| Gets the unique identifier for the server instance. | |
| 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, TcpSession > | Sessions [get] |
| Gets the collection of active sessions. | |
| int | ConnectedSessions [get] |
| Gets the number of connected 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. | |
Represents a WebSocket server that inherits from HttpServer and implements WebSocket functionality.
|
virtual |
Broadcasts a message to all connected WebSocket sessions.
| buffer | The buffer containing the message to broadcast. |
Reimplemented from XmobiTea.ProtonNetServer.TcpServer.
|
virtual |
Broadcasts a message to all connected WebSocket sessions with a specified position and length.
| buffer | The buffer containing the message to broadcast. |
| position | The starting position in the buffer. |
| length | The length of the data to broadcast. |
Reimplemented from XmobiTea.ProtonNetServer.TcpServer.
|
virtual |
Asynchronously broadcasts a message to all connected WebSocket sessions.
| buffer | The buffer containing the message to broadcast. |
Reimplemented from XmobiTea.ProtonNetServer.TcpServer.
|
virtual |
Asynchronously broadcasts a message to all connected WebSocket sessions with a specified position and length.
| buffer | The buffer containing the message to broadcast. |
| position | The starting position in the buffer. |
| length | The length of the data to broadcast. |
Reimplemented from XmobiTea.ProtonNetServer.TcpServer.
|
virtual |
Closes all WebSocket sessions with a default status code of 0.
Implements XmobiTea.ProtonNetServer.IWsServer.
|
virtual |
Closes all WebSocket sessions with the specified status code.
| status | The status code to use when closing the sessions. |
Implements XmobiTea.ProtonNetServer.IWsServer.
|
virtual |
Closes all WebSocket sessions with the specified status code and an additional buffer.
| status | The status code to use when closing the sessions. |
| buffer | The buffer containing additional data to send before closing the sessions. |
Implements XmobiTea.ProtonNetServer.IWsServer.
|
virtual |
Closes all WebSocket sessions with the specified status code, buffer, and offset/size parameters.
| status | The status code to use when closing the sessions. |
| buffer | The buffer containing additional data to send before closing the sessions. |
| offset | The offset in the buffer where the data begins. |
| size | The size of the data to send. |
Implements XmobiTea.ProtonNetServer.IWsServer.
|
protectedvirtual |
Initializes a new instance of the WsServer class with the specified address, port, and options.
| address | The server's IP address. |
| port | The server's port number. |
| options | The TCP server options. |
Creates a new WebSocket session.
Reimplemented from XmobiTea.ProtonNetServer.HttpServer.
| bool XmobiTea.ProtonNetServer.WsServer.MulticastBinary | ( | byte[] | buffer | ) |
Sends a binary message to all connected WebSocket sessions.
| buffer | The buffer containing the binary message to multicast. |
Implements XmobiTea.ProtonNetServer.IWsServer.
| bool XmobiTea.ProtonNetServer.WsServer.MulticastBinary | ( | byte[] | buffer, |
| int | position, | ||
| int | length ) |
Sends a binary message to all connected WebSocket sessions with a specified position and length.
| buffer | The buffer containing the binary message to multicast. |
| position | The starting position in the buffer. |
| length | The length of the data to multicast. |
Implements XmobiTea.ProtonNetServer.IWsServer.
| bool XmobiTea.ProtonNetServer.WsServer.MulticastBinaryAsync | ( | byte[] | buffer | ) |
Asynchronously sends a binary message to all connected WebSocket sessions.
| buffer | The buffer containing the binary message to multicast. |
Implements XmobiTea.ProtonNetServer.IWsServer.
| bool XmobiTea.ProtonNetServer.WsServer.MulticastBinaryAsync | ( | byte[] | buffer, |
| int | position, | ||
| int | length ) |
Asynchronously sends a binary message to all connected WebSocket sessions with a specified position and length.
| buffer | The buffer containing the binary message to multicast. |
| position | The starting position in the buffer. |
| length | The length of the data to multicast. |
Implements XmobiTea.ProtonNetServer.IWsServer.
| bool XmobiTea.ProtonNetServer.WsServer.MulticastPing | ( | byte[] | buffer | ) |
Sends a ping message to all connected WebSocket sessions.
| buffer | The buffer containing the ping message to multicast. |
Implements XmobiTea.ProtonNetServer.IWsServer.
| bool XmobiTea.ProtonNetServer.WsServer.MulticastPing | ( | byte[] | buffer, |
| int | position, | ||
| int | length ) |
Sends a ping message to all connected WebSocket sessions with a specified position and length.
| buffer | The buffer containing the ping message to multicast. |
| position | The starting position in the buffer. |
| length | The length of the data to multicast. |
Implements XmobiTea.ProtonNetServer.IWsServer.
| bool XmobiTea.ProtonNetServer.WsServer.MulticastPingAsync | ( | byte[] | buffer | ) |
Asynchronously sends a ping message to all connected WebSocket sessions.
| buffer | The buffer containing the ping message to multicast. |
Implements XmobiTea.ProtonNetServer.IWsServer.
| bool XmobiTea.ProtonNetServer.WsServer.MulticastPingAsync | ( | byte[] | buffer, |
| int | position, | ||
| int | length ) |
Asynchronously sends a ping message to all connected WebSocket sessions with a specified position and length.
| buffer | The buffer containing the ping message to multicast. |
| position | The starting position in the buffer. |
| length | The length of the data to multicast. |
Implements XmobiTea.ProtonNetServer.IWsServer.
| bool XmobiTea.ProtonNetServer.WsServer.MulticastText | ( | byte[] | buffer | ) |
Sends a text message to all connected WebSocket sessions.
| buffer | The buffer containing the text message to multicast. |
Implements XmobiTea.ProtonNetServer.IWsServer.
| bool XmobiTea.ProtonNetServer.WsServer.MulticastText | ( | byte[] | buffer, |
| int | position, | ||
| int | length ) |
Sends a text message to all connected WebSocket sessions with a specified position and length.
| buffer | The buffer containing the text message to multicast. |
| position | The starting position in the buffer. |
| length | The length of the data to multicast. |
Implements XmobiTea.ProtonNetServer.IWsServer.
| bool XmobiTea.ProtonNetServer.WsServer.MulticastTextAsync | ( | byte[] | buffer | ) |
Asynchronously sends a text message to all connected WebSocket sessions.
| buffer | The buffer containing the text message to multicast. |
Implements XmobiTea.ProtonNetServer.IWsServer.
| bool XmobiTea.ProtonNetServer.WsServer.MulticastTextAsync | ( | byte[] | buffer, |
| int | position, | ||
| int | length ) |
Asynchronously sends a text message to all connected WebSocket sessions with a specified position and length.
| buffer | The buffer containing the text message to multicast. |
| position | The starting position in the buffer. |
| length | The length of the data to multicast. |
Implements XmobiTea.ProtonNetServer.IWsServer.
| void XmobiTea.ProtonNetServer.WsServer.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.
| buffer | The close data buffer. |
| position | The starting position in the buffer. |
| length | The length of the close data. |
| status | The close status code. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
| void XmobiTea.ProtonNetServer.WsServer.OnWsConnected | ( | HttpRequest | request | ) |
Called when a WebSocket connection is successfully established. Override this method to add custom logic after WebSocket connection.
| request | The HTTP request for the WebSocket connection. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
| void XmobiTea.ProtonNetServer.WsServer.OnWsConnected | ( | HttpResponse | response | ) |
Called when a WebSocket connection is successfully established. Override this method to add custom logic after WebSocket connection.
| response | The HTTP response for the WebSocket connection. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
| void XmobiTea.ProtonNetServer.WsServer.OnWsConnecting | ( | HttpRequest | request | ) |
Called when a WebSocket connection is being established. Override this method to add custom logic during WebSocket connection.
| request | The HTTP request for the WebSocket connection. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
| bool XmobiTea.ProtonNetServer.WsServer.OnWsConnecting | ( | HttpRequest | request, |
| HttpResponse | response ) |
Called when a WebSocket connection is being established. Override this method to add custom logic during WebSocket connection.
| request | The HTTP request for the WebSocket connection. |
| response | The HTTP response for the WebSocket connection. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
| void XmobiTea.ProtonNetServer.WsServer.OnWsDisconnected | ( | ) |
Called when a WebSocket connection is successfully disconnected. Override this method to add custom logic after WebSocket disconnection.
Implements XmobiTea.ProtonNetCommon.IWebSocket.
| void XmobiTea.ProtonNetServer.WsServer.OnWsDisconnecting | ( | ) |
Called when a WebSocket connection is being disconnected. Override this method to add custom logic during WebSocket disconnection.
Implements XmobiTea.ProtonNetCommon.IWebSocket.
| void XmobiTea.ProtonNetServer.WsServer.OnWsError | ( | SocketError | error | ) |
Called when a WebSocket error occurs. Override this method to handle WebSocket errors with a SocketError instance.
| error | The SocketError that occurred. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
| void XmobiTea.ProtonNetServer.WsServer.OnWsError | ( | string | error | ) |
Called when a WebSocket error occurs. Override this method to handle WebSocket errors with a custom message.
| error | The error message. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
| void XmobiTea.ProtonNetServer.WsServer.OnWsPing | ( | byte[] | buffer, |
| int | position, | ||
| int | length ) |
Called when a WebSocket ping is received. Override this method to handle WebSocket ping events.
| buffer | The ping data buffer. |
| position | The starting position in the buffer. |
| length | The length of the ping data. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
| void XmobiTea.ProtonNetServer.WsServer.OnWsPong | ( | byte[] | buffer, |
| int | position, | ||
| int | length ) |
Called when a WebSocket pong is received. Override this method to handle WebSocket pong events.
| buffer | The pong data buffer. |
| position | The starting position in the buffer. |
| length | The length of the pong data. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
| void XmobiTea.ProtonNetServer.WsServer.OnWsReceived | ( | byte[] | buffer, |
| int | position, | ||
| int | length ) |
Called when data is received from the WebSocket connection. Override this method to process received data.
| buffer | The received data buffer. |
| position | The starting position in the buffer. |
| length | The length of the received data. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.
| void XmobiTea.ProtonNetServer.WsServer.SendUpgrade | ( | HttpResponse | response | ) |
Sends a WebSocket upgrade response to the client.
| response | The HTTP response containing the WebSocket upgrade information. |
Implements XmobiTea.ProtonNetCommon.IWebSocket.