1
0
mirror of https://github.com/chylex/Minecraft-Phantom-Panel.git synced 2025-05-09 23:34:11 +02:00

Fix Server not marking Agent as connected if a keep-alive packet arrives after a temporary packet loss

This commit is contained in:
chylex 2023-02-07 23:37:54 +01:00
parent 71a5babb73
commit 7a209d1d71
Signed by: chylex
GPG Key ID: 4DE42C8F19A80548
2 changed files with 6 additions and 1 deletions
Server/Phantom.Server.Services/Agents

View File

@ -24,6 +24,11 @@ public sealed record Agent(
internal Agent(AgentInfo info) : this(info.Guid, info.Name, info.ProtocolVersion, info.BuildVersion, info.MaxInstances, info.MaxMemory, info.AllowedServerPorts, info.AllowedRconPorts) {}
internal Agent AsOnline(DateTimeOffset lastPing) => this with {
LastPing = lastPing,
IsOnline = Connection != null
};
internal Agent AsDisconnected() => this with {
IsOnline = false
};

View File

@ -101,7 +101,7 @@ public sealed class AgentManager {
}
internal void NotifyAgentIsAlive(Guid agentGuid) {
agents.ByGuid.TryReplace(agentGuid, static agent => agent with { LastPing = DateTimeOffset.Now });
agents.ByGuid.TryReplace(agentGuid, static agent => agent.AsOnline(DateTimeOffset.Now));
}
internal void SetAgentStats(Guid agentGuid, int runningInstanceCount, RamAllocationUnits runningInstanceMemory) {