Host closing server closes all connections and closes the listener.

This commit is contained in:
alzeih
2010-07-23 18:00:26 +12:00
committed by Chris Forbes
parent 05d0e825fd
commit 409416b55c
2 changed files with 11 additions and 1 deletions

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Server
static class Server
{
static List<Connection> conns = new List<Connection>();
static TcpListener listener;
static TcpListener listener = null;
static Dictionary<int, List<Connection>> inFlightFrames
= new Dictionary<int, List<Connection>>();
static Session lobbyInfo;
@@ -425,6 +425,14 @@ namespace OpenRA.Server
SyncLobbyInfo();
}
public static void CloseServer()
{
while (conns.Count() != 0)
DropClient(conns.ElementAt(conns.Count() - 1), null);
if (listener != null)
listener.Stop();
}
static void SyncLobbyInfo()
{
var clientData = lobbyInfo.Clients.ToDictionary(

View File

@@ -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;
};