本文整理汇总了C#中OpenRA.Server.Server.Shutdown方法的典型用法代码示例。如果您正苦于以下问题:C# Server.Shutdown方法的具体用法?C# Server.Shutdown怎么用?C# Server.Shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenRA.Server.Server
的用法示例。
在下文中一共展示了Server.Shutdown方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
var arguments = new Arguments(args);
Log.AddChannel("debug", "dedicated-debug.log");
Log.AddChannel("perf", "dedicated-perf.log");
Log.AddChannel("server", "dedicated-server.log");
Log.AddChannel("nat", "dedicated-nat.log");
// Special case handling of Game.Mod argument: if it matches a real filesystem path
// then we use this to override the mod search path, and replace it with the mod id
var modArgument = arguments.GetValue("Game.Mod", null);
string customModPath = null;
if (modArgument != null && (File.Exists(modArgument) || Directory.Exists(modArgument)))
{
customModPath = modArgument;
arguments.ReplaceValue("Game.Mod", Path.GetFileNameWithoutExtension(modArgument));
}
// HACK: The engine code assumes that Game.Settings is set.
// This isn't nearly as bad as ModData, but is still not very nice.
Game.InitializeSettings(arguments);
var settings = Game.Settings.Server;
var mod = Game.Settings.Game.Mod;
var mods = new InstalledMods(customModPath);
// HACK: The engine code *still* assumes that Game.ModData is set
var modData = Game.ModData = new ModData(mods[mod], mods);
modData.MapCache.LoadMaps();
settings.Map = modData.MapCache.ChooseInitialMap(settings.Map, new MersenneTwister());
Console.WriteLine("[{0}] Starting dedicated server for mod: {1}", DateTime.Now.ToString(settings.TimestampFormat), mod);
while (true)
{
var server = new Server(new IPEndPoint(IPAddress.Any, settings.ListenPort), settings, modData, true);
while (true)
{
Thread.Sleep(1000);
if (server.State == ServerState.GameStarted && server.Conns.Count < 1)
{
Console.WriteLine("[{0}] No one is playing, shutting down...", DateTime.Now.ToString(settings.TimestampFormat));
server.Shutdown();
break;
}
}
Console.WriteLine("[{0}] Starting a new server instance...", DateTime.Now.ToString(settings.TimestampFormat));
}
}
示例2: Main
static void Main(string[] args)
{
Log.AddChannel("debug", "dedicated-debug.log");
Log.AddChannel("perf", "dedicated-perf.log");
Log.AddChannel("server", "dedicated-server.log");
// HACK: The engine code assumes that Game.Settings is set.
// This isn't nearly as bad as ModData, but is still not very nice.
Game.InitializeSettings(new Arguments(args));
var settings = Game.Settings.Server;
// HACK: The engine code *still* assumes that Game.ModData is set
var mod = Game.Settings.Game.Mod;
var modData = Game.ModData = new ModData(mod, false);
modData.MapCache.LoadMaps();
settings.Map = modData.MapCache.ChooseInitialMap(settings.Map, new MersenneTwister());
Console.WriteLine("[{0}] Starting dedicated server for mod: {1}", DateTime.Now.ToString(settings.TimestampFormat), mod);
while (true)
{
var server = new Server(new IPEndPoint(IPAddress.Any, settings.ListenPort), settings, modData, true);
while (true)
{
Thread.Sleep(1000);
if (server.State == ServerState.GameStarted && server.Conns.Count < 1)
{
Console.WriteLine("[{0}] No one is playing, shutting down...", DateTime.Now.ToString(settings.TimestampFormat));
server.Shutdown();
break;
}
}
Console.WriteLine("[{0}] Starting a new server instance...", DateTime.Now.ToString(settings.TimestampFormat));
}
}