This commit is contained in:
2025-08-21 07:20:08 +02:00
committed by Jeroen Saey
parent 1a15416613
commit bdf2d1b935
5 changed files with 341 additions and 279 deletions

View File

@@ -35,26 +35,21 @@ namespace EonaCat.Connections.Server.Example
var config = new Configuration
{
Protocol = ProtocolType.TCP,
Port = 8080,
UseSsl = true,
UseAesEncryption = true,
Port = 1111,
UseSsl = false,
UseAesEncryption = false,
MaxConnections = 100000,
ServerCertificate = new System.Security.Cryptography.X509Certificates.X509Certificate2("server.pfx", "p@ss"),
//ServerCertificate = new System.Security.Cryptography.X509Certificates.X509Certificate2("server.pfx", "p@ss"),
};
_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) =>
{
@@ -72,10 +67,7 @@ namespace EonaCat.Connections.Server.Example
};
_server.OnDisconnected += (sender, e) =>
{
Console.WriteLine($"Client {e.ClientId} disconnected");
Console.Title = $"Active Connections: {--totalClients}";
};
await _server.StartAsync();
}