feat : 에코 서버 / 클라이언트 기능 추가 작업

This commit is contained in:
qornwh1
2026-03-01 01:05:14 +09:00
parent 30457819b1
commit 97f6187f5d
13 changed files with 255 additions and 133 deletions

View File

@@ -1,28 +1,37 @@
using ClientTester.EchoDummyService;
using Serilog;
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.CreateLogger();
const string SERVER_IP = "localhost";
const int SERVER_PORT = 9500;
const string CONNECTION_KEY = "game";
const int CLIENT_COUNT = 1000;
var cts = new CancellationTokenSource();
Console.CancelKeyPress += (_, e) =>
class EcoClientTester
{
e.Cancel = true;
Log.Warning("[SHUTDOWN] Ctrl+C 감지, 종료 중...");
cts.Cancel();
};
public static readonly string SERVER_IP = "localhost";
public static readonly int SERVER_PORT = 9500;
public static readonly string CONNECTION_KEY = "test";
public static readonly int CLIENT_COUNT = 100;
var service = new DummyClientService(CLIENT_COUNT, SERVER_IP, SERVER_PORT, CONNECTION_KEY, 100);
private static async Task Main(string[] args)
{
Log.Logger = new LoggerConfiguration().WriteTo.Console().CreateLogger();
await service.RunAsync(cts.Token);
CancellationTokenSource cts = new CancellationTokenSource();
Console.CancelKeyPress += (_, e) =>
{
e.Cancel = true;
Log.Warning("[SHUTDOWN] Ctrl+C 감지, 종료 중...");
cts.Cancel();
};
service.PrintStats();
service.Stop();
DummyClientService service = new DummyClientService(CLIENT_COUNT, SERVER_IP, SERVER_PORT, CONNECTION_KEY, 100);
service.OnAllDisconnected += async () =>
{
Log.Warning("[SHUTDOWN] 종료 이벤트 발생, 종료 중...");
await cts.CancelAsync();
};
Log.CloseAndFlush();
await service.RunAsync(cts.Token);
service.PrintStats();
service.Stop();
await Log.CloseAndFlushAsync();
}
}