Added client title counter in example
This commit is contained in:
@@ -43,13 +43,18 @@ namespace EonaCat.Connections.Server.Example
|
||||
};
|
||||
|
||||
_server = new NetworkServer(config);
|
||||
|
||||
int totalClients = 0;
|
||||
// Subscribe to events
|
||||
_server.OnConnected += (sender, e) =>
|
||||
{
|
||||
Console.WriteLine($"Client {e.ClientId} connected from {e.RemoteEndPoint}");
|
||||
Console.Title = $"Active Connections: {++totalClients}";
|
||||
};
|
||||
|
||||
_server.OnConnectedWithNickname += (sender, e) =>
|
||||
{
|
||||
Console.WriteLine($"Client {e.ClientId} connected with nickname: {e.Nickname}");
|
||||
};
|
||||
|
||||
_server.OnDataReceived += async (sender, e) =>
|
||||
{
|
||||
@@ -67,7 +72,10 @@ namespace EonaCat.Connections.Server.Example
|
||||
};
|
||||
|
||||
_server.OnDisconnected += (sender, e) =>
|
||||
{
|
||||
Console.WriteLine($"Client {e.ClientId} disconnected");
|
||||
Console.Title = $"Active Connections: {--totalClients}";
|
||||
};
|
||||
|
||||
await _server.StartAsync();
|
||||
}
|
||||
|
Reference in New Issue
Block a user