diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index a6c6405e56..0fc9b16d1d 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -24,7 +24,7 @@ namespace OpenRA.Server static class Server { static List conns = new List(); - static TcpListener listener; + static TcpListener listener = null; static Dictionary> inFlightFrames = new Dictionary>(); static Session lobbyInfo; @@ -424,6 +424,14 @@ namespace OpenRA.Server if (conns.Count != 0) SyncLobbyInfo(); } + + public static void CloseServer() + { + while (conns.Count() != 0) + DropClient(conns.ElementAt(conns.Count() - 1), null); + if (listener != null) + listener.Stop(); + } static void SyncLobbyInfo() { diff --git a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs index 1e8a25ea7b..8646a72c5b 100644 --- a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs @@ -80,6 +80,8 @@ namespace OpenRA.Widgets.Delegates var disconnectButton = lobby.GetWidget("DISCONNECT_BUTTON"); disconnectButton.OnMouseUp = mi => { + if (Game.IsHost) + Server.Server.CloseServer(); Game.Disconnect(); return true; };