Merge branch 'fix_by_claude' of https://git.tolelom.xyz/A301/a301_mmo_game_server
This commit is contained in:
@@ -18,6 +18,7 @@ public class DummyClients
|
||||
// seq → 송신 타임스탬프 (Stopwatch tick)
|
||||
private ConcurrentDictionary<int, long> pendingPings = new();
|
||||
private int seqNumber;
|
||||
private const int MaxPendingPings = 1000;
|
||||
|
||||
// 유닛 테스트용 (0 = 제한 없음)
|
||||
public int TestCount
|
||||
@@ -117,9 +118,20 @@ public class DummyClients
|
||||
int seq = seqNumber++;
|
||||
pendingPings[seq] = Stopwatch.GetTimestamp();
|
||||
|
||||
// 응답 없는 오래된 ping 정리 (패킷 유실 시 메모리 누수 방지)
|
||||
if (pendingPings.Count > MaxPendingPings)
|
||||
{
|
||||
int cutoff = seq - MaxPendingPings;
|
||||
foreach (int key in pendingPings.Keys)
|
||||
{
|
||||
if (key < cutoff)
|
||||
pendingPings.TryRemove(key, out _);
|
||||
}
|
||||
}
|
||||
|
||||
PacketHeader packetHeader = new PacketHeader();
|
||||
packetHeader.Code = 0;
|
||||
packetHeader.BodyLength = $"seq:{seq}".Length;
|
||||
packetHeader.BodyLength = $"Echo seq:{seq}".Length;
|
||||
writer.Put((short)packetHeader.Code);
|
||||
writer.Put((short)packetHeader.BodyLength);
|
||||
writer.Put($"Echo seq:{seq}");
|
||||
|
||||
Reference in New Issue
Block a user