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 network issues. The method takes a single parameter, reason
, which is a string that describes why the client is being kicked. This reason can be logged or displayed to the client to provide context for the disconnection.
Usage
To use the Kick
method, you need to have an instance of the Connection
class. You can then call the method on this instance, passing in a string that explains the reason for the kick. This method is virtual, allowing derived classes to override its behavior if necessary.
Example
// Example of using the Kick method
Connection connection = ...; // Assume this is an existing connection
string reason = "Violation of server rules";
connection.Kick(reason);