diff --git a/Supervisor/NBloodServerListener.cs b/Supervisor/NBloodServerListener.cs index 33c0268..a384266 100644 --- a/Supervisor/NBloodServerListener.cs +++ b/Supervisor/NBloodServerListener.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Net; using System.Net.Sockets; using System.Text; +using System.Threading; namespace Supervisor { @@ -37,6 +38,9 @@ namespace Supervisor case 'C': ProcessFragsPacket(buffer); break; + case 'D': + ProcessRemovePacket(message); + break; default: break; } @@ -150,6 +154,27 @@ namespace Supervisor }); } + private static void ProcessRemovePacket(string message) + { + string[] splitMessage = message.SplitMessage(); + var packetData = new RemoveServer() + { + Port = int.Parse(splitMessage[0]) + }; + + UpdateState(packetData); + } + + private static void UpdateState(RemoveServer packetData) + { + bool isSuccess; + do + { + isSuccess = Program.State.Servers.TryRemove(packetData.Port, out _); + Thread.Sleep(TimeSpan.FromSeconds(1)); + } while (!isSuccess); + } + private static string GetGameType(int gameType) { return gameType switch diff --git a/Supervisor/Frags.cs b/Supervisor/Packets/Frags.cs similarity index 100% rename from Supervisor/Frags.cs rename to Supervisor/Packets/Frags.cs diff --git a/Supervisor/PacketData.cs b/Supervisor/Packets/PacketData.cs similarity index 100% rename from Supervisor/PacketData.cs rename to Supervisor/Packets/PacketData.cs diff --git a/Supervisor/PlayerCounts.cs b/Supervisor/Packets/PlayerCounts.cs similarity index 100% rename from Supervisor/PlayerCounts.cs rename to Supervisor/Packets/PlayerCounts.cs diff --git a/Supervisor/PlayerNames.cs b/Supervisor/Packets/PlayerNames.cs similarity index 100% rename from Supervisor/PlayerNames.cs rename to Supervisor/Packets/PlayerNames.cs diff --git a/Supervisor/Packets/RemoveServer.cs b/Supervisor/Packets/RemoveServer.cs new file mode 100644 index 0000000..b26f0b3 --- /dev/null +++ b/Supervisor/Packets/RemoveServer.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Supervisor +{ + class RemoveServer : PacketData + { + public RemoveServer() + { + IsStarted = false; + } + } +} diff --git a/WebInterface/Supervisor.runtimeconfig.json b/WebInterface/Supervisor.runtimeconfig.json new file mode 100644 index 0000000..a3b9e3d --- /dev/null +++ b/WebInterface/Supervisor.runtimeconfig.json @@ -0,0 +1,9 @@ +{ + "runtimeOptions": { + "tfm": "netcoreapp3.1", + "framework": { + "name": "Microsoft.NETCore.App", + "version": "3.1.0" + } + } +} \ No newline at end of file diff --git a/WebInterface/WebInterface.csproj b/WebInterface/WebInterface.csproj index c254cf2..16d315c 100644 --- a/WebInterface/WebInterface.csproj +++ b/WebInterface/WebInterface.csproj @@ -12,6 +12,7 @@ +