IServerConnectionsProvider
IServerConnectionsProvider
is an interface designed for connection-oriented protocols, particularly TCP. This interface monitors the status of connected clients, tracks connection usage, and triggers events related to connection changes.
Purpose:
Monitoring Connection Status:
IServerConnectionsProvider
tracks the status of clients that establish a connection. This includes scenarios where clients connect or disconnect from the server.Monitoring Resource Usage: It also tracks the connection usage and resource consumption of connected clients.
Supported Protocols:
TCP Protocol: TCP is a connection-oriented protocol that ensures reliable data transmission. It allows the server to monitor the status of connected clients and the connection usage.
IServerConnectionsProvider
supports only the TCP protocol, as this protocol requires establishing a connection and provides the ability to track connection statuses. UDP, being a connectionless protocol, is not supported by the IServerConnectionsProvider
interface.
Converting from ISocketServer to IServerConnectionsProvider:
The IServerConnectionsProvider
interface may be derived from the ISocketServer
interface. To transition from ISocketServer
to IServerConnectionsProvider
, you can use a classic type casting. This allows you to access the features of IServerConnectionsProvider
from a specific socketServer
instance.
Type Casting Example:
This code snippet checks if the socketServer
instance supports the IServerConnectionsProvider
interface. If it does, the type casting is done, and you can access information such as client connection status and resource usage through this instance.
Additional Event:
OnClientConnectionChanged: This event is triggered when a client connects or disconnects from the server. The event handler receives the EndPoint (representing the client’s address) and a boolean value indicating whether the client has connected (
true
) or disconnected (false
)
Operations:
The IServerConnectionsProvider interface provides essential functions for monitoring client connections and tracking server resource usage. These functionalities are vital for managing and maintaining the performance of a server handling client connections. The interface allows you to retrieve the list of connected clients and monitor the connection usage rate.
These operations depend on the proper configuration of the server to function effectively and provide accurate data on connected clients and resource utilization.
Last updated