static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; Config = new ServerConfig(); bool loaded = args.Length > 1 ? Config.Load(args[1]) : Config.Load(); if (Config.SplashScreen == true) { Logger.WriteLine(" __ _______ ____ _____", false); Logger.WriteLine(" \\ \\ / / ____|/ __ \\ / ____|", false); Logger.WriteLine(" \\ \\_/ / | __| | | | | ___ _ __ ___", false); Logger.WriteLine(" \\ /| | |_ | | | | | / _ \\| '__/ _ \\", false); Logger.WriteLine(" | | | |__| | |__| | |___| (_) | | | __/", false); Logger.WriteLine(" |_| \\_____|\\____/ \\_____\\___/|_| \\___| Version: " + Version, false); Logger.WriteLine(string.Empty, false); } Logger.WriteLine("Accepting client version 0x" + Config.ClientVersion.ToString("x") + " or higher."); if (loaded) Console.WriteLine("Config loaded."); else Console.WriteLine("Unable to load config.txt, using default settings."); int coreport = 0; if (args.Length > 0) int.TryParse(args[0], out coreport); Random = new Random(); Server server = new Server(); if (!server.Start(coreport)) Thread.Sleep(5000); if (server.IsListening == true && Config.STDOUT == true) Console.WriteLine("::::network-ready"); while (server.IsListening) { server.Process(); Thread.Sleep(1); } if (Config.STDOUT == true) Console.WriteLine("::::network-end"); Process.GetCurrentProcess().Kill(); }
public static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress); System.Net.ServicePointManager.DefaultConnectionLimit = 512; ThreadPool.SetMaxThreads(128, 256); // Config = new ServerConfig(); bool loaded = args.Length > 0 ? Config.Load(args[0]): Config.Load(); int tmp = 0; if (args.Length > 1) { int.TryParse(args[1], out tmp); if (tmp > 0) { Config.SetServerPort(tmp); } } if (args.Length > 2) { int.TryParse(args[2], out tmp); if (tmp > 0) { Config.SetApiPort(tmp); } } if (args.Length > 3) { Config.SetNeedAuth(args[3].Trim().ToLower() == "true"); } Logger.SetErrorFile(Tool.Combine(Config.Path, "error_" + DateTime.UtcNow.ToString("yyyy-MM-dd") + "_" + Config.ServerPort + ".log")); Logger.SetLogLevel(Config.LogLevel); #if DEBUG Logger.SetLogLevel(LogLevel.Debug); #endif Console.Title = "GameServer:" + Config.ServerPort; GameServer Server = new GameServer(Config); Server.WriteHead(); if (loaded) { Logger.Debug("Config loaded."); } else { Logger.Warn("Unable to load config.txt, using default settings."); } if (!Server.Start()) { Console.WriteLine(">>server start fail."); Console.ReadKey(); } else { Command(Server); } }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress); Config = new ServerConfig(); bool loaded = args.Length > 0 ? Config.Load(args[0]): Config.Load(); ChatCommand.WriteHead(Config); if (loaded) { Logger.WriteLine("Config loaded."); } else { Logger.WriteLine("Unable to load config.txt, using default settings."); } if (Config.HandShuffle) { Logger.WriteLine("Warning: Hand shuffle requires a custom ocgcore to work."); } int coreport = Config.ServerPort; // // if (args.Length > 0){ // int.TryParse(args[0], out coreport); // if(coreport==0){ // coreport=Config.ServerPort; // }else{ // Config.setValue("serverport", ""+coreport); // if(coreport<=9999){ // Config.setValue("apiport", ""+(10000+coreport)); // } // } // } Random = new Random(); Server server = new Server(); if (!server.Start(coreport)) { Thread.Sleep(5000); } ThreadPool.SetMaxThreads(128, 256); Thread inputThread = new Thread(new ParameterizedThreadStart(Command)); inputThread.IsBackground = true; inputThread.Start(server); while (server.IsListening) { server.Process(); Thread.Sleep(1); } }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; Config = new ServerConfig(); bool loaded = args.Length > 1 ? Config.Load(args[1]): Config.Load(); Logger.WriteLine(" __ _______ ____ _____", false); Logger.WriteLine(" \\ \\ / / ____|/ __ \\ / ____|", false); Logger.WriteLine(" \\ \\_/ / | __| | | | | ___ _ __ ___", false); Logger.WriteLine(" \\ /| | |_ | | | | | / _ \\| '__/ _ \\", false); Logger.WriteLine(" | | | |__| | |__| | |___| (_) | | | __/", false); Logger.WriteLine(" |_| \\_____|\\____/ \\_____\\___/|_| \\___| Version: " + Version, false); Logger.WriteLine(string.Empty, false); if (loaded) { Logger.WriteLine("Config loaded."); } else { Logger.WriteLine("Unable to load config.txt, using default settings."); } Logger.WriteLine("Accepting client version 0x" + Config.ClientVersion.ToString("x") + " or better."); int coreport = 0; if (args.Length > 0) { int.TryParse(args[0], out coreport); } Random = new Random(); Server server = new Server(); if (!server.Start(coreport)) { Thread.Sleep(5000); } while (server.IsListening) { server.Process(); Thread.Sleep(1); } }
public static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; Console.CancelKeyPress+= new ConsoleCancelEventHandler(Console_CancelKeyPress); System.Net.ServicePointManager.DefaultConnectionLimit = 512; ThreadPool.SetMaxThreads(128, 256); // Config = new ServerConfig(); bool loaded = args.Length > 0 ? Config.Load(args[0]): Config.Load(); int tmp =0 ; if(args.Length > 1){ int.TryParse(args[1], out tmp); if(tmp > 0){ Config.SetServerPort(tmp); } } if(args.Length > 2){ int.TryParse(args[2], out tmp); if(tmp > 0){ Config.SetApiPort(tmp); } } if(args.Length > 3) { Config.SetNeedAuth(args[3].Trim().ToLower() == "true"); } Logger.SetErrorFile(Tool.Combine(Config.Path, "error_"+ DateTime.UtcNow.ToString("yyyy-MM-dd")+"_"+Config.ServerPort + ".log")); Logger.SetLogLevel(Config.LogLevel); #if DEBUG Logger.SetLogLevel(LogLevel.Debug); #endif Console.Title = "GameServer:"+Config.ServerPort; GameServer Server = new GameServer(Config); Server.WriteHead(); if(loaded) Logger.Debug("Config loaded."); else Logger.Warn("Unable to load config.txt, using default settings."); if (!Server.Start()){ Console.WriteLine(">>server start fail."); Console.ReadKey(); }else{ Command(Server); } }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; Console.CancelKeyPress+= new ConsoleCancelEventHandler(Console_CancelKeyPress); Config = new ServerConfig(); bool loaded = args.Length > 0 ? Config.Load(args[0]): Config.Load(); ChatCommand.WriteHead(Config); if(loaded) Logger.WriteLine("Config loaded."); else Logger.WriteLine("Unable to load config.txt, using default settings."); if(Config.HandShuffle){ Logger.WriteLine("Warning: Hand shuffle requires a custom ocgcore to work."); } int coreport = Config.ServerPort; // // if (args.Length > 0){ // int.TryParse(args[0], out coreport); // if(coreport==0){ // coreport=Config.ServerPort; // }else{ // Config.setValue("serverport", ""+coreport); // if(coreport<=9999){ // Config.setValue("apiport", ""+(10000+coreport)); // } // } // } Random = new Random(); Server server = new Server(); if (!server.Start(coreport)) Thread.Sleep(5000); ThreadPool.SetMaxThreads(128, 256); Thread inputThread=new Thread(new ParameterizedThreadStart(Command)); inputThread.IsBackground=true; inputThread.Start(server); while (server.IsListening) { server.Process(); Thread.Sleep(1); } }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; Config = new ServerConfig(); bool loaded = args.Length > 1 ? Config.Load(args[1]) : Config.Load(); if (Config.SplashScreen == true) { Logger.WriteLine(" __ _______ ____ _____", false); Logger.WriteLine(" \\ \\ / / ____|/ __ \\ / ____|", false); Logger.WriteLine(" \\ \\_/ / | __| | | | | ___ _ __ ___", false); Logger.WriteLine(" \\ /| | |_ | | | | | / _ \\| '__/ _ \\", false); Logger.WriteLine(" | | | |__| | |__| | |___| (_) | | | __/", false); Logger.WriteLine(" |_| \\_____|\\____/ \\_____\\___/|_| \\___| Version: " + Version, false); Logger.WriteLine(string.Empty, false); } Logger.WriteLine("Accepting client version 0x" + Config.ClientVersion.ToString("x") + " or higher."); if (loaded) { Console.WriteLine("Config loaded."); } else { Console.WriteLine("Unable to load config.ini, using default settings."); } int coreport = 0; if (args.Length > 0) { int.TryParse(args[0], out coreport); } Random = new Random(); Server server = new Server(); if (!server.Start(coreport)) { Thread.Sleep(5000); } if (server.IsListening == true && Config.STDOUT == true) { Console.WriteLine("::::network-ready"); } while (server.IsListening) { server.Process(); Thread.Sleep(1); } if (Config.STDOUT == true) { Console.WriteLine("::::network-end"); } if (Config.Recycle == false) { System.Environment.Exit(0); } }