Compare commits
3 Commits
fix_by_cla
...
a9e1d2acaf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9e1d2acaf | ||
|
|
e3f365877b | ||
|
|
01d107def3 |
@@ -8,6 +8,19 @@ public class DummyClientService
|
||||
private readonly List<DummyClients> clients;
|
||||
private readonly int sendInterval;
|
||||
|
||||
// 유닛 테스트용 (n패킷 시간체크)
|
||||
public bool IsTest
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = false;
|
||||
|
||||
public int TestCount
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = 100000;
|
||||
|
||||
// 모든거 강종
|
||||
public event Action? OnAllDisconnected;
|
||||
|
||||
@@ -21,6 +34,16 @@ public class DummyClientService
|
||||
|
||||
public async Task RunAsync(CancellationToken ct)
|
||||
{
|
||||
if (IsTest)
|
||||
{
|
||||
foreach (DummyClients c in clients)
|
||||
{
|
||||
c.TestCount = TestCount;
|
||||
}
|
||||
|
||||
Log.Information("[TEST] 유닛 테스트 모드: 클라이언트당 {Count}개 수신 시 자동 종료", TestCount);
|
||||
}
|
||||
|
||||
await Task.WhenAll(
|
||||
PollLoopAsync(ct),
|
||||
SendLoopAsync(ct)
|
||||
@@ -103,6 +126,7 @@ public class DummyClientService
|
||||
{
|
||||
int totalSent = 0, totalRecv = 0;
|
||||
int connected = 0;
|
||||
int rttClientCount = 0;
|
||||
|
||||
Log.Information("───────────── Performance Report ─────────────");
|
||||
|
||||
@@ -120,14 +144,18 @@ public class DummyClientService
|
||||
|
||||
totalSent += c.SentCount;
|
||||
totalRecv += c.ReceivedCount;
|
||||
totalAvgRtt += c.AvgRttMs;
|
||||
if (c.RttCount > 0)
|
||||
{
|
||||
totalAvgRtt += c.AvgRttMs;
|
||||
rttClientCount++;
|
||||
}
|
||||
if (c.peer != null)
|
||||
{
|
||||
connected++;
|
||||
}
|
||||
}
|
||||
|
||||
double avgRtt = connected > 0 ? totalAvgRtt / connected : 0;
|
||||
double avgRtt = rttClientCount > 0 ? totalAvgRtt / rttClientCount : 0;
|
||||
|
||||
Log.Information("────────────────────────────────────────────");
|
||||
Log.Information(
|
||||
|
||||
@@ -20,6 +20,13 @@ public class DummyClients
|
||||
private int seqNumber;
|
||||
private const int MaxPendingPings = 1000;
|
||||
|
||||
// 유닛 테스트용 (0 = 제한 없음)
|
||||
public int TestCount
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = 0;
|
||||
|
||||
// 통계
|
||||
public int SentCount
|
||||
{
|
||||
@@ -82,6 +89,12 @@ public class DummyClients
|
||||
}
|
||||
|
||||
ReceivedCount++;
|
||||
|
||||
if (TestCount > 0 && ReceivedCount >= TestCount)
|
||||
{
|
||||
peer.Disconnect();
|
||||
}
|
||||
|
||||
reader.Recycle();
|
||||
};
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ class EcoClientTester
|
||||
cts.Cancel();
|
||||
};
|
||||
|
||||
// service.IsTest = true;
|
||||
// service.TestCount = 100;
|
||||
await service.RunAsync(cts.Token);
|
||||
|
||||
service.PrintStats();
|
||||
|
||||
@@ -36,11 +36,25 @@ public abstract class ServerBase : INetEventListener
|
||||
// peer → hashKey 역방향은 peer.Tag as Session 으로 대체
|
||||
private readonly Dictionary<long, NetPeer> sessions = new();
|
||||
|
||||
// 핑 로그 출력 여부
|
||||
public bool PingLogRtt { get; set; }
|
||||
// 재사용 NetDataWriter (단일 스레드 폴링이므로 안전)
|
||||
private readonly NetDataWriter cachedWriter = new();
|
||||
|
||||
public int Port { get; }
|
||||
public string ConnectionString { get; }
|
||||
// 핑 로그 출력 여부
|
||||
public bool PingLogRtt
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public int Port
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public string ConnectionString
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
private volatile bool isListening = false;
|
||||
|
||||
@@ -71,6 +85,7 @@ public abstract class ServerBase : INetEventListener
|
||||
netManager.PollEvents();
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
netManager.Stop();
|
||||
Log.Information("[Server] 종료 Port={Port}", Port);
|
||||
}
|
||||
@@ -112,6 +127,7 @@ public abstract class ServerBase : INetEventListener
|
||||
Log.Information("[Server] 세션 해제 HashKey={Key} Reason={Reason}", session.HashKey, disconnectInfo.Reason);
|
||||
OnSessionDisconnected(peer, session.HashKey, disconnectInfo);
|
||||
}
|
||||
|
||||
peer.Tag = null;
|
||||
}
|
||||
}
|
||||
@@ -235,9 +251,6 @@ public abstract class ServerBase : INetEventListener
|
||||
|
||||
// ─── 전송 헬퍼 ───────────────────────────────────────────────────────
|
||||
|
||||
// 재사용 NetDataWriter (단일 스레드 폴링이므로 안전)
|
||||
private readonly NetDataWriter cachedWriter = new();
|
||||
|
||||
// peer에게 전송
|
||||
protected void SendTo(NetPeer peer, byte[] data, DeliveryMethod method = DeliveryMethod.ReliableOrdered)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user