public ISControl(ISManager manager) { _manager = manager; // listen to control communications _manager.AddHandler <ControlMsg>(Channel.Control, HandleControl); }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += LogUnhandledException; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Config = args.Length > 0 ? ServerConfig.ReadFile(args[0]) : ServerConfig.ReadFile("server.json"); Environment.SetEnvironmentVariable("ServerLogFolder", Config.serverSettings.logFolder); GlobalContext.Properties["ServerName"] = Config.serverInfo.name; GlobalContext.Properties["ServerType"] = Config.serverInfo.type.ToString(); XmlConfigurator.ConfigureAndWatch(new FileInfo(Config.serverSettings.log4netConfig)); using (Resources = new Resources(Config.serverSettings.resourceFolder)) using (Database = new Database( Config.dbInfo.host, Config.dbInfo.port, Config.dbInfo.auth, Config.dbInfo.index, Resources)) { RequestHandlers.Initialize(Resources); Config.serverInfo.instanceId = Guid.NewGuid().ToString(); ISManager = new ISManager(Database, Config); ISManager.Run(); ChatManager = new ChatManager(ISManager); ISControl = new ISControl(ISManager); Console.CancelKeyPress += delegate { Shutdown.Set(); }; var port = Config.serverInfo.port; using (var server = new HttpServer($"http://{Config.serverInfo.bindAddress}:{port}/")) { foreach (var uri in RequestHandlers.Get.Keys) { server.GET(uri).Subscribe(Response); } foreach (var uri in RequestHandlers.Post.Keys) { server.POST(uri).Subscribe(Response); } Log.Info("Listening at port " + port + "..."); Shutdown.WaitOne(); } Log.Info("Terminating..."); ISManager.Dispose(); } }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += LogUnhandledException; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Config = args.Length > 0 ? ServerConfig.ReadFile(args[0]) : ServerConfig.ReadFile("server.json"); LogManager.Configuration.Variables["logDirectory"] = Config.serverSettings.logFolder + "/server"; LogManager.Configuration.Variables["buildConfig"] = Utils.GetBuildConfiguration(); using (Resources = new Resources(Config.serverSettings.resourceFolder, false)) using (Database = new Database(Resources, Config)) { RequestHandlers.Initialize(Resources); Config.serverInfo.instanceId = Guid.NewGuid().ToString(); ISManager = new ISManager(Database, Config); ISManager.Run(); ChatManager = new ChatManager(ISManager); ISControl = new ISControl(ISManager); LegendSweeper = new LegendSweeper(Database); LegendSweeper.Run(); Console.CancelKeyPress += delegate { Shutdown.Set(); }; var port = Config.serverInfo.port; var address = Config.serverInfo.bindAddress; using (var server = new HttpServer($"http://{address}:{port}/")) { foreach (var uri in RequestHandlers.Get.Keys) { server.GET(uri).Subscribe(Response); } foreach (var uri in RequestHandlers.Post.Keys) { server.POST(uri).Subscribe(Response); } Log.Info("Listening at address {0}:{1}...", address, port); Shutdown.WaitOne(); } Log.Info("Terminating..."); ISManager.Dispose(); } }
private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("resources/config/log4net_server.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; using (Settings = new Settings("resources/config/server")) using (Database = new Database( Settings.GetValue("db_host", "127.0.0.1"), Settings.GetValue <int>("db_port", "6379"), Settings.GetValue("db_auth", ""))) { GameData = new XmlData(); InstanceId = Guid.NewGuid().ToString(); var port = Settings.GetValue <int>("port", "8880"); listener = new HttpListener(); listener.Prefixes.Add($"http://*:{port}/"); listener.Start(); listener.BeginGetContext(ListenerCallback, null); Console.CancelKeyPress += (sender, e) => e.Cancel = true; Logger.Info("Listening at port " + port + "..."); ISManager manager = new ISManager(); manager.Run(); while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } Logger.Info("Terminating..."); while (currentRequests.Count > 0) { ; } manager.Dispose(); listener.Stop(); //GameData.Dispose(); } }
static void Main(string[] args) { Console.Title = "Stable Account Server"; Console.WindowWidth = 110; XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; using (Settings = new SimpleSettings("server")) using (Database = new Database( Settings.GetValue <string>("db_host", "127.0.0.1"), Settings.GetValue <int>("db_port", "6379"), Settings.GetValue <string>("db_auth", ""))) { GameData = new XmlData(); InstanceId = Guid.NewGuid().ToString(); int port = Settings.GetValue <int>("port", "8888"); listener = new HttpListener(); listener.Prefixes.Add("http://*:" + port + "/"); listener.Start(); listener.BeginGetContext(ListenerCallback, null); Console.CancelKeyPress += (sender, e) => e.Cancel = true; log.Info("Listening at port " + port + "..."); ISManager manager = new ISManager(); manager.Run(); while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } log.Info("Terminating..."); manager.Dispose(); listener.Stop(); GameData.Dispose(); } }