From 0604a585815021f739922bc4a6ae5446506fbe3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 22 Aug 2021 19:59:39 +0200 Subject: [PATCH] Send a ping when the server is shut down and stop the LAN beacon. --- .../ServerTraits/MasterServerPinger.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs b/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs index c4a0a3d9a4..fe4608e4bc 100644 --- a/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs +++ b/OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs @@ -22,7 +22,7 @@ using S = OpenRA.Server.Server; namespace OpenRA.Mods.Common.Server { - public class MasterServerPinger : ServerTrait, ITick, INotifyServerStart, INotifySyncLobbyInfo, IStartGame, IEndGame + public class MasterServerPinger : ServerTrait, ITick, INotifyServerStart, INotifyServerShutdown, INotifySyncLobbyInfo, IStartGame, IEndGame { // 3 minutes (in milliseconds). Server has a 5 minute TTL for games, so give ourselves a bit of leeway. const int MasterPingInterval = 60 * 3 * 1000; @@ -82,12 +82,24 @@ namespace OpenRA.Mods.Common.Server server.SendMessage(masterServerMessages.Dequeue()); } - public void ServerStarted(S server) + void INotifyServerStart.ServerStarted(S server) { if (server.Type != ServerType.Local && LanGameBeacon != null) LanGameBeacon.Start(); } + void INotifyServerShutdown.ServerShutdown(S server) + { + if (server.Settings.AdvertiseOnline) + { + // Announce that the game has ended to remove it from the list. + var gameServer = new GameServer(server); + UpdateMasterServer(server, gameServer.ToPOSTData(false)); + } + + LanGameBeacon?.Stop(); + } + public void LobbyInfoSynced(S server) { lastChanged = Game.RunTime;