|
ProtonNet Server 1.0
An Open Solution for all your socket or web api needs.
|
Represents a TCP server that can handle multiple client sessions. More...
Public Member Functions | |
| 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 | BroadcastAll (byte[] buffer) |
| Broadcasts a message to all connected sessions. | |
| virtual bool | BroadcastAll (byte[] buffer, int position, int length) |
| Broadcasts a message to all connected sessions with a specified position and length. | |
| virtual bool | BroadcastAllAsync (byte[] buffer) |
| Broadcasts a message asynchronously to all connected sessions. | |
| virtual bool | BroadcastAllAsync (byte[] buffer, int position, int length) |
| Broadcasts a message asynchronously to all connected sessions with a specified position and length. | |
| 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 | |
Protected Member Functions | |
| virtual string | CreateRandomId () |
| Creates a random identifier for the server. | |
| virtual TcpSession | CreateSession () |
| Creates a new session. Override this method to provide custom session behavior. | |
| 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. | |
Properties | |
| 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 TCP server that can handle multiple client sessions.
| 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.
| address | The server's IP address. |
| port | The server's port number. |
| options | The TCP server options. |
|
virtual |
Broadcasts a message to all connected sessions.
| buffer | The data buffer to broadcast. |
Implements XmobiTea.ProtonNetServer.IServer.
Reimplemented in XmobiTea.ProtonNetServer.WsServer.
|
virtual |
Broadcasts a message to all connected sessions with a specified position and length.
| buffer | The data buffer to broadcast. |
| position | The starting position in the buffer. |
| length | The length of the data to broadcast. |
Implements XmobiTea.ProtonNetServer.IServer.
Reimplemented in XmobiTea.ProtonNetServer.WsServer.
|
virtual |
Broadcasts a message asynchronously to all connected sessions.
| buffer | The data buffer to broadcast. |
Implements XmobiTea.ProtonNetServer.IServer.
Reimplemented in XmobiTea.ProtonNetServer.WsServer.
|
virtual |
Broadcasts a message asynchronously to all connected sessions with a specified position and length.
| buffer | The data buffer to broadcast. |
| position | The starting position in the buffer. |
| length | The length of the data to broadcast. |
Implements XmobiTea.ProtonNetServer.IServer.
Reimplemented in XmobiTea.ProtonNetServer.WsServer.
|
protectedvirtual |
Creates a random identifier for the server.
|
protectedvirtual |
Creates a new session. Override this method to provide custom session behavior.
Reimplemented in XmobiTea.ProtonNet.Server.Socket.Server.SocketTcpServer, XmobiTea.ProtonNet.Server.Socket.Server.SocketWsServer, XmobiTea.ProtonNet.Server.WebApi.Server.WebApiHttpServer, XmobiTea.ProtonNetServer.HttpServer, and XmobiTea.ProtonNetServer.WsServer.
|
virtual |
Disconnects all connected sessions.
Implements XmobiTea.ProtonNetServer.IServer.
|
protectedvirtual |
Disposes the server, optionally releasing managed resources.
| disposingManagedResources | True to release managed resources; otherwise, false. |
| IServerNetworkStatistics XmobiTea.ProtonNetServer.TcpServer.GetNetworkStatistics | ( | ) |
Gets the network statistics for the server.
Implements XmobiTea.ProtonNetServer.IServer.
| TcpSession XmobiTea.ProtonNetServer.TcpServer.GetSession | ( | string | id | ) |
Finds a session by its identifier.
| id | The session identifier. |
|
protectedvirtual |
Called after a session has connected successfully. Override this method to handle session-specific logic after the connection process.
| session | The session that has connected. |
|
protectedvirtual |
Called when a session is connecting. Override this method to handle session-specific logic during the connection process.
| session | The session that is connecting. |
|
protectedvirtual |
Called after a session has disconnected successfully. Override this method to handle session-specific logic after the disconnection process.
| session | The session that has disconnected. |
|
protectedvirtual |
Called when a session is disconnecting. Override this method to handle session-specific logic during the disconnection process.
| session | The session that is disconnecting. |
|
protectedvirtual |
Called when a socket error occurs. Override this method to handle errors in a custom way.
| error | The SocketError that occurred. |
|
virtual |
Restarts the TCP server.
Implements XmobiTea.ProtonNetServer.IServer.
|
virtual |
Starts the TCP server.
Implements XmobiTea.ProtonNetServer.IServer.
|
virtual |
Stops the TCP server.
Implements XmobiTea.ProtonNetServer.IServer.