Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove games from the server list when the host presses leave #19627

Merged
merged 1 commit into from Sep 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions OpenRA.Mods.Common/ServerTraits/MasterServerPinger.cs
Expand Up @@ -22,7 +22,7 @@

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;
Expand Down Expand Up @@ -82,12 +82,24 @@ public void Tick(S 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;
Expand Down