Host closing server closes all connections and closes the listener.
This commit is contained in:
@@ -24,7 +24,7 @@ namespace OpenRA.Server
|
|||||||
static class Server
|
static class Server
|
||||||
{
|
{
|
||||||
static List<Connection> conns = new List<Connection>();
|
static List<Connection> conns = new List<Connection>();
|
||||||
static TcpListener listener;
|
static TcpListener listener = null;
|
||||||
static Dictionary<int, List<Connection>> inFlightFrames
|
static Dictionary<int, List<Connection>> inFlightFrames
|
||||||
= new Dictionary<int, List<Connection>>();
|
= new Dictionary<int, List<Connection>>();
|
||||||
static Session lobbyInfo;
|
static Session lobbyInfo;
|
||||||
@@ -425,6 +425,14 @@ namespace OpenRA.Server
|
|||||||
SyncLobbyInfo();
|
SyncLobbyInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void CloseServer()
|
||||||
|
{
|
||||||
|
while (conns.Count() != 0)
|
||||||
|
DropClient(conns.ElementAt(conns.Count() - 1), null);
|
||||||
|
if (listener != null)
|
||||||
|
listener.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
static void SyncLobbyInfo()
|
static void SyncLobbyInfo()
|
||||||
{
|
{
|
||||||
var clientData = lobbyInfo.Clients.ToDictionary(
|
var clientData = lobbyInfo.Clients.ToDictionary(
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
var disconnectButton = lobby.GetWidget("DISCONNECT_BUTTON");
|
var disconnectButton = lobby.GetWidget("DISCONNECT_BUTTON");
|
||||||
disconnectButton.OnMouseUp = mi =>
|
disconnectButton.OnMouseUp = mi =>
|
||||||
{
|
{
|
||||||
|
if (Game.IsHost)
|
||||||
|
Server.Server.CloseServer();
|
||||||
Game.Disconnect();
|
Game.Disconnect();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user