feat : 더미 플레이어 구현 / 더미클라 서비스 에코용, 더미 플레이어용 분기
This commit is contained in:
@@ -1,47 +1,116 @@
|
||||
using ClientTester.DummyService;
|
||||
using ClientTester.EchoDummyService;
|
||||
using Serilog;
|
||||
|
||||
class EcoClientTester
|
||||
{
|
||||
public static readonly string SERVER_IP = "tolelom.xyz";
|
||||
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;
|
||||
|
||||
private async void StartEchoDummyTest()
|
||||
{
|
||||
try
|
||||
{
|
||||
CancellationTokenSource cts = new CancellationTokenSource();
|
||||
Console.CancelKeyPress += (_, e) =>
|
||||
{
|
||||
e.Cancel = true;
|
||||
Log.Warning("[SHUTDOWN] Ctrl+C 감지, 종료 중...");
|
||||
cts.Cancel();
|
||||
};
|
||||
|
||||
EchoDummyClientService service =
|
||||
new EchoDummyClientService(CLIENT_COUNT, SERVER_IP, SERVER_PORT, CONNECTION_KEY, 100);
|
||||
service.OnAllDisconnected += () =>
|
||||
{
|
||||
Log.Warning("[SHUTDOWN] 종료 이벤트 발생, 종료 중...");
|
||||
cts.Cancel();
|
||||
};
|
||||
|
||||
// service.IsTest = true;
|
||||
// service.TestCount = 100;
|
||||
await service.RunAsync(cts.Token);
|
||||
|
||||
service.PrintStats();
|
||||
service.Stop();
|
||||
|
||||
await Log.CloseAndFlushAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error($"[SHUTDOWN] 예외 발생 : {e}");
|
||||
}
|
||||
}
|
||||
|
||||
private async void StartDummyTest()
|
||||
{
|
||||
try
|
||||
{
|
||||
CancellationTokenSource cts = new CancellationTokenSource();
|
||||
Console.CancelKeyPress += (_, e) =>
|
||||
{
|
||||
e.Cancel = true;
|
||||
Log.Warning("[SHUTDOWN] Ctrl+C 감지, 종료 중...");
|
||||
cts.Cancel();
|
||||
};
|
||||
|
||||
DummyClientService service =
|
||||
new DummyClientService(CLIENT_COUNT, SERVER_IP, SERVER_PORT, CONNECTION_KEY, 100);
|
||||
service.OnAllDisconnected += () =>
|
||||
{
|
||||
Log.Warning("[SHUTDOWN] 종료 이벤트 발생, 종료 중...");
|
||||
cts.Cancel();
|
||||
};
|
||||
|
||||
await service.RunAsync(cts.Token);
|
||||
|
||||
service.PrintStats();
|
||||
service.Stop();
|
||||
|
||||
await Log.CloseAndFlushAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error($"[SHUTDOWN] 예외 발생 : {e}");
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task Main(string[] args)
|
||||
{
|
||||
// .MinimumLevel.Warning() // Warning 이상만 출력 배포시
|
||||
|
||||
string timestamp = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
|
||||
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.MinimumLevel.Debug()
|
||||
.WriteTo.Console()
|
||||
.WriteTo.File($"logs/log_{timestamp}.txt")
|
||||
.WriteTo.File($"logs2/log_{timestamp}.txt")
|
||||
.CreateLogger();
|
||||
|
||||
CancellationTokenSource cts = new CancellationTokenSource();
|
||||
Console.CancelKeyPress += (_, e) =>
|
||||
Log.Information("========== 더미 클라 테스터 ==========");
|
||||
Log.Information("1. 에코 서버");
|
||||
Log.Information("2. 더미 클라(이동만)");
|
||||
Log.Information("====================================");
|
||||
Log.Information("1 / 2 : ");
|
||||
|
||||
string? input = Console.ReadLine();
|
||||
if (!int.TryParse(input, out int choice) || (choice != 1 && choice != 2))
|
||||
{
|
||||
e.Cancel = true;
|
||||
Log.Warning("[SHUTDOWN] Ctrl+C 감지, 종료 중...");
|
||||
cts.Cancel();
|
||||
};
|
||||
Log.Warning("1 또는 2만 입력하세요.");
|
||||
return;
|
||||
}
|
||||
|
||||
DummyClientService service = new DummyClientService(CLIENT_COUNT, SERVER_IP, SERVER_PORT, CONNECTION_KEY, 100);
|
||||
service.OnAllDisconnected += () =>
|
||||
EcoClientTester tester = new EcoClientTester();
|
||||
if (choice == 1)
|
||||
{
|
||||
Log.Warning("[SHUTDOWN] 종료 이벤트 발생, 종료 중...");
|
||||
cts.Cancel();
|
||||
};
|
||||
|
||||
// service.IsTest = true;
|
||||
// service.TestCount = 100;
|
||||
await service.RunAsync(cts.Token);
|
||||
|
||||
service.PrintStats();
|
||||
service.Stop();
|
||||
|
||||
await Log.CloseAndFlushAsync();
|
||||
// 에코 서버 실행
|
||||
tester.StartEchoDummyTest();
|
||||
}
|
||||
else if (choice == 2)
|
||||
{
|
||||
// 더미 클라 실행
|
||||
tester.StartDummyTest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user