feat : 더미 플레이어 구현 / 더미클라 서비스 에코용, 더미 플레이어용 분기

This commit is contained in:
qornwh1
2026-03-04 08:55:27 +09:00
parent d2ba2ccb48
commit 9930348d5e
10 changed files with 678 additions and 287 deletions

View File

@@ -3,9 +3,9 @@ using Serilog;
namespace ClientTester.EchoDummyService;
public class DummyClientService
public class EchoDummyClientService
{
private readonly List<DummyClients> clients;
private readonly List<EchoDummyClients> clients;
private readonly int sendInterval;
// 유닛 테스트용 (n패킷 시간체크)
@@ -24,10 +24,10 @@ public class DummyClientService
// 모든거 강종
public event Action? OnAllDisconnected;
public DummyClientService(int count, string ip, int port, string key, int sendIntervalMs = 1000)
public EchoDummyClientService(int count, string ip, int port, string key, int sendIntervalMs = 1000)
{
sendInterval = sendIntervalMs;
clients = Enumerable.Range(0, count).Select(i => new DummyClients(i, ip, port, key)).ToList();
clients = Enumerable.Range(0, count).Select(i => new EchoDummyClients(i, ip, port, key)).ToList();
Log.Information("[SERVICE] {Count}개 클라이언트 생성 → {Ip}:{Port}", count, ip, port);
}
@@ -36,7 +36,7 @@ public class DummyClientService
{
if (IsTest)
{
foreach (DummyClients c in clients)
foreach (EchoDummyClients c in clients)
{
c.TestCount = TestCount;
}
@@ -54,7 +54,7 @@ public class DummyClientService
{
while (!ct.IsCancellationRequested)
{
foreach (DummyClients c in clients)
foreach (EchoDummyClients c in clients)
{
c.PollEvents();
}
@@ -72,15 +72,6 @@ public class DummyClientService
private async Task SendLoopAsync(CancellationToken ct)
{
try
{
await Task.Delay(500, ct);
}
catch (OperationCanceledException)
{
return;
}
int tick = 0;
while (!ct.IsCancellationRequested)
@@ -88,7 +79,7 @@ public class DummyClientService
int sent = 0;
int total = clients.Count;
foreach (DummyClients client in clients)
foreach (EchoDummyClients client in clients)
{
client.SendPing();
if (client.peer != null)
@@ -132,7 +123,7 @@ public class DummyClientService
double totalAvgRtt = 0;
foreach (DummyClients c in clients)
foreach (EchoDummyClients c in clients)
{
NetStatistics? stats = c.peer?.Statistics;
long loss = stats?.PacketLoss ?? 0;
@@ -166,7 +157,7 @@ public class DummyClientService
public void Stop()
{
foreach (DummyClients c in clients)
foreach (EchoDummyClients c in clients)
{
c.Stop();
}

View File

@@ -7,7 +7,7 @@ using Serilog;
namespace ClientTester.EchoDummyService;
public class DummyClients
public class EchoDummyClients
{
private NetManager manager;
private EventBasedNetListener listener;
@@ -58,7 +58,7 @@ public class DummyClients
get;
}
public DummyClients(int clientId, string ip, int port, string key)
public EchoDummyClients(int clientId, string ip, int port, string key)
{
this.clientId = clientId;
listener = new EventBasedNetListener();
@@ -131,7 +131,7 @@ public class DummyClients
PacketHeader packetHeader = new PacketHeader();
packetHeader.Code = 0;
packetHeader.BodyLength = $"Echo seq:{seq}".Length;
packetHeader.BodyLength = (ushort)$"Echo seq:{seq}".Length;
writer.Put((short)packetHeader.Code);
writer.Put((short)packetHeader.BodyLength);
writer.Put($"Echo seq:{seq}");

View File

@@ -0,0 +1,6 @@
namespace ClientTester.EchoDummyService;
public class Map
{
// TODO : 맵 정보 필요
}