clean up game timeout
This commit is contained in:
@@ -18,11 +18,12 @@ using System.Net.Sockets;
|
|||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
using UPnP;
|
using UPnP;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Timers;
|
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
|
|
||||||
|
using XTimer = System.Timers.Timer;
|
||||||
|
|
||||||
namespace OpenRA.Server
|
namespace OpenRA.Server
|
||||||
{
|
{
|
||||||
public class Server
|
public class Server
|
||||||
@@ -48,6 +49,7 @@ namespace OpenRA.Server
|
|||||||
public ServerSettings Settings;
|
public ServerSettings Settings;
|
||||||
public ModData ModData;
|
public ModData ModData;
|
||||||
public Map Map;
|
public Map Map;
|
||||||
|
XTimer gameTimeout;
|
||||||
|
|
||||||
volatile bool shutdown = false;
|
volatile bool shutdown = false;
|
||||||
public void Shutdown() { shutdown = true; }
|
public void Shutdown() { shutdown = true; }
|
||||||
@@ -469,20 +471,16 @@ namespace OpenRA.Server
|
|||||||
t.GameStarted(this);
|
t.GameStarted(this);
|
||||||
|
|
||||||
// Check TimeOut
|
// Check TimeOut
|
||||||
if ( Game.Settings.Server.TimeOut > 10000 )
|
if ( Settings.TimeOut > 10000 )
|
||||||
{
|
{
|
||||||
aTimer = new System.Timers.Timer(Game.Settings.Server.TimeOut);
|
gameTimeout = new XTimer(Settings.TimeOut);
|
||||||
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
|
gameTimeout.Elapsed += (_,e) =>
|
||||||
aTimer.Enabled = true;
|
{
|
||||||
|
Console.WriteLine("Timeout at {0}!!!", e.SignalTime);
|
||||||
|
Environment.Exit(0);
|
||||||
|
};
|
||||||
|
gameTimeout.Enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static System.Timers.Timer aTimer;
|
|
||||||
|
|
||||||
private static void OnTimedEvent(object source, ElapsedEventArgs e)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Started game has Timed Out at {0} !!!", e.SignalTime);
|
|
||||||
System.Environment.Exit(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user