Description
The Kick
method is used to disconnect a client from the server. This method is typically called when a client needs to be removed from the server for a specific reason, such as violating rules or due to a network issue. The method is virtual, allowing derived classes to override its behavior if necessary.
Usage
To use the Kick
method, you need to have an instance of the Connection
class. You can call this method by passing a string parameter that specifies the reason for the disconnection. This reason is often communicated to the client to inform them why they have been disconnected.
Example
// Example of using the Kick method
public void DisconnectClient(Connection connection, string reason)
{
if (connection != null)
{
connection.Kick(reason);
}
}