private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_wServer.config")); Settings = new SimpleSettings("wServer"); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; svrSkt = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); svrSkt.Bind(new IPEndPoint(IPAddress.Any, 2050)); svrSkt.Listen(0xff); svrSkt.BeginAccept(Listen, null); Console.CancelKeyPress += (sender, e) => { logger.Info("Saving Please Wait..."); svrSkt.Close(); foreach (var i in RealmManager.Clients.Values.ToArray()) { i.Save(); i.Disconnect(); } logger.Info("Closing..."); Thread.Sleep(500); Environment.Exit(0); }; logger.Info("Listening at port 2050..."); HostPolicyServer(); RealmManager.CoreTickLoop(); //Never returns }
public void Initialize(string configFilepath, bool isTestMode, SimpleSettings settings, IDataRepository dataManager) { try { if (!File.Exists(configFilepath)) { throw new FileNotFoundException($"{configFilepath} was not found"); } XDocument xDocument = XDocument.Load(configFilepath); var elkurl = xDocument.Element("ELKUrl")?.Value; _elasticClient = new ElasticClient(new Uri(elkurl)); _elasticLowLevelClient = new ElasticLowLevelClient( new ConnectionConfiguration(new SniffingConnectionPool(new List <Uri>() { new Uri(elkurl) }))); _indexPath = new List <string>(); _addDocumentQueue = new ConcurrentBag <object[]>(); Task.Factory.StartNew(new Action(UpdateNodeRun)); } catch (Exception e) { Logger.Error(e, "Initialize"); } }
private static void Main() { XmlConfigurator.Configure(); try { var settings = SimpleSettings.Create("settings"); CryptoConfig.AddAlgorithm(typeof(RHHE), RHHE.Name); var sleepPeriod = int.Parse(settings.GetValue("sleep")); var ttl = int.Parse(settings.GetValue("ttl")); var server = PrepareServer(settings); var wsServer = PrepareWsServer(settings); SecretHolder.Init(settings.GetValue("secret")); CredentialsHolder.Init(settings.GetValue("credentials"), sleepPeriod); PointHolder.Init(settings.GetValue("points"), sleepPeriod, ttl, (point, msg) => wsServer.BroadcastAsync(point, msg, CancellationToken.None)); Task .WhenAll( server.AcceptLoopAsync(CancellationToken.None), wsServer.AcceptLoopAsync(CancellationToken.None) ) .Wait(); } catch (Exception ex) { Console.Error.WriteLine(ex); Log.Fatal("Unexpected exception", ex); Environment.Exit(ex.HResult == 0 ? ex.HResult : -1); } }
public async Task CanLoadUsingConsulConfigurationProvider() { var keyname = Guid.NewGuid().ToString(); using (var configRegistry = new ConsulRegistry(null)) { await configRegistry.SetKeyAsync($"org/{keyname}/test1", _value1); await configRegistry.SetKeyAsync($"org/{keyname}/test2", _value2); await configRegistry.SetKeyAsync($"org/{keyname}/Nested/test3", _value3); await configRegistry.SetKeyAsync($"org/{keyname}/Nested/test4", _value4); await configRegistry.AddStaticKeyPathAsync($"org"); var config = new ConfigurationBuilder() .AddConfigurationRegistry(configRegistry) .Build(); var simpleSettings = new SimpleSettings(); var configSection = config.GetSection(keyname); configSection.Bind(simpleSettings); Assert.Equal(_value1, simpleSettings.Test1); Assert.Equal(_value2, simpleSettings.Test2); Assert.Equal(_value3, simpleSettings.Nested.Test3); Assert.Equal(_value4, simpleSettings.Nested.Test4); } }
public void GetSetStringProperty_SimpleSettings_Ok(bool isSynchronized) { SimpleSettings settings = isSynchronized ? (SimpleSettings)SettingsBase.Synchronized(new SimpleSettings()) : new SimpleSettings(); Assert.Equal(default, settings.StringProperty);
private static void Main(string[] args) { Console.Title = "Zy's Realm - World Server"; try { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Settings = new SimpleSettings("wServer"); new Database( Settings.GetValue <string>("db_host", "127.0.0.1"), Settings.GetValue <string>("db_database", "rotmgprod"), Settings.GetValue <string>("db_user", "root"), Settings.GetValue <string>("db_auth", "")); manager = new RealmManager( Settings.GetValue <int>("maxClients", "100"), Settings.GetValue <int>("tps", "20")); WhiteList = Settings.GetValue <bool>("whiteList", "false"); DebugMode = Settings.GetValue <bool>("debugMode", "false"); manager.Initialize(); manager.Run(); Server server = new Server(manager); PolicyServer policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); if (Settings.GetValue <bool>("broadcastNews", "false") && File.Exists("news.txt")) { new Thread(autoBroadcastNews).Start(); } Console.WriteLine("Server initialized."); if (isStopped()) { Console.WriteLine("Terminating..."); server.Stop(); policy.Stop(); manager.Stop(); Console.WriteLine("Server terminated."); } } catch (Exception e) { Console.WriteLine(e); foreach (var c in manager.Clients) { c.Value.Disconnect(Client.DisconnectReason.STOPPING_SERVER); } Console.ReadLine(); } }
public virtual void Initialize(string configFilepath, bool isTestMode, SimpleSettings settings, IDataRepository dataRepository) { IsTestMode = isTestMode; ConfigFilepath = configFilepath; Settings = settings ?? new SimpleSettings(); DataRepository = dataRepository; IsConfigUpdated = true; }
public void Context_SimpleSettings_InNotNull(bool isSynchronized) { SimpleSettings settings = isSynchronized ? (SimpleSettings)SettingsBase.Synchronized(new SimpleSettings()) : new SimpleSettings(); Assert.NotNull(settings.Context); }
public void Providers_SimpleSettings_Empty(bool isSynchronized) { SimpleSettings settings = isSynchronized ? (SimpleSettings)SettingsBase.Synchronized(new SimpleSettings()) : new SimpleSettings(); Assert.Equal(1, settings.Providers.Count); Assert.NotNull(settings.Providers[typeof(LocalFileSettingsProvider).Name]); }
private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_server.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Settings = new SimpleSettings("server"); Database = new Database( Settings.GetValue <string>("db_host", "127.0.0.1"), Settings.GetValue <string>("db_database", "rotmgprod"), Settings.GetValue <string>("db_user", "root"), Settings.GetValue <string>("db_auth", "")); GameData = new XmlData(); InstanceId = Guid.NewGuid().ToString(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; var port = Settings.GetValue <int>("port", "8888"); if (RunPreCheck(port)) { try { listener = new HttpListener(); listener.Prefixes.Add($"http://*:{port}/"); //listener.Prefixes.Add($"http://localhost:{port}/"); listener.Start(); listener.BeginGetContext(ListenerCallback, null); Logger.Info($"Listening at port {port}..."); }catch (Exception ex) { Logger.Error($"Error: {ex.Message}"); } } else { Logger.Error($"Port {port} is occupied. Can't start listening...\nPress ESC to exit."); } while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } Logger.Info("Terminating..."); //To prevent a char/list account in use if //both servers are closed at the same time while (currentRequests.Count > 0) { ; } listener?.Stop(); GameData.Dispose(); }
public void GetSetIntProperty_SimpleSettings_Ok(bool isSynchronized) { SimpleSettings settings = isSynchronized ? (SimpleSettings)SettingsBase.Synchronized(new SimpleSettings()) : new SimpleSettings(); Assert.Equal(DefaultIntPropertyValue, settings.IntProperty); settings.IntProperty = 10; Assert.Equal(10, settings.IntProperty); }
public void Reload_SimpleSettings_Ok() { var settings = new SimpleSettings(); settings.IntProperty = 10; Assert.NotEqual(DefaultIntPropertyValue, settings.IntProperty); settings.Reload(); Assert.Equal(DefaultIntPropertyValue, settings.IntProperty); }
public AppConfig(string[] args) { var settings = new SimpleSettings(); settings.AddCommandlineArgs(args); settings.AddTextConfigSettings("simpleSmtpServer.config.txt"); settings.AddAppConfigSettings("simpleSmtpServer."); MailsFolder = settings.GetString("simpleSmtpServer.mailsFolder"); ClearMailsOnStartup = settings.GetBool("simpleSmtpServer.clearMailsOnStartup"); Port = settings.GetEnum("port", Ports.SMTP); }
private static void Main(string[] args) { Console.Title = "TEST Account Server"; { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_server.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Settings = new SimpleSettings("server"); Database = new Database( Settings.GetValue <string>("db_host", "127.0.0.1"), Settings.GetValue <string>("db_database", "Nxl"), Settings.GetValue <string>("db_user", "root"), Settings.GetValue <string>("db_auth", "")); GameData = new XmlData(); InstanceId = Guid.NewGuid().ToString(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; var port = Settings.GetValue <int>("port", "80"); if (RunPreCheck(port)) { listener = new HttpListener(); listener.Prefixes.Add($"http://*:{port}/"); listener.Start(); listener.BeginGetContext(ListenerCallback, null); Logger.Info($"TEST account server is now running!"); } else { Logger.Error($"Port {port} is occupied. Can't start listening...\nPress ESC to exit. \nPlease check if you are running any programs that could use the port \nTry end tasking the srvrhost process."); } while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } Logger.Info("Terminating..."); //To prevent a char/list account in use if //both servers are closed at the same time while (currentRequests.Count > 0) { ; } listener?.Stop(); GameData.Dispose(); } }
public DataListenerSetting(string name, string configFile = "", bool isTestMode = false, SimpleSettings settings = null) { Name = name; ConfigFile = configFile; IsTestMode = isTestMode; Settings = new SimpleSettings(); if (settings != null) { foreach (KeyValuePair <string, string> keyValuePair in settings) { Settings[keyValuePair.Key] = keyValuePair.Value; } } }
private static void Main(string[] args) { Console.Title = "Zy's Realm - Server"; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Settings = new SimpleSettings("server"); Database = new Database( Settings.GetValue <string>("db_host", "127.0.0.1"), Settings.GetValue <string>("db_database", "rotmgprod"), Settings.GetValue <string>("db_user", "root"), Settings.GetValue <string>("db_auth", "")); GameData = new XmlData(); InstanceId = Guid.NewGuid().ToString(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; var port = Settings.GetValue <int>("port", "80"); if (RunPreCheck(port)) { listener = new HttpListener(); listener.Prefixes.Add($"http://*:{port}/"); listener.Start(); listener.BeginGetContext(ListenerCallback, null); Console.WriteLine($"Listening at port {port}..."); } else { Console.WriteLine($"Port {port} is occupied. Can't start listening...\nPress ESC to exit."); } while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } Console.WriteLine("Terminating..."); //To prevent a char/list account in use if //both servers are closed at the same time while (currentRequests.Count > 0) { ; } listener?.Stop(); GameData.Dispose(); }
private static HttpServer PrepareServer(SimpleSettings settings) { var port = int.Parse(settings.GetValue("port")); var server = new HttpServer(port); server .AddHandler(LoginHandler.Instance) .AddHandler(AddPointHandler.Instance) .AddHandler(GetAllPublicsHandler.Instance) .AddHandler(GetPointsHandler.Instance) .AddHandler(ShortestPathHandler.Instance); return(server); }
static void Main(string[] args) { Console.Title = "Stable World Server"; Console.WindowWidth = 110; XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; using (Settings = new SimpleSettings("wServer")) using (var db = new Database( Settings.GetValue <string>("db_host", "127.0.0.1"), Settings.GetValue <int>("db_port", "6379"), Settings.GetValue <string>("db_auth", ""))) { RealmManager manager = new RealmManager( Settings.GetValue <int>("maxClient", "100"), Settings.GetValue <int>("tps", "20"), db); manager.Initialize(); manager.Run(); Server server = new Server(manager, 2050); PolicyServer policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); log.Info("Server initialized."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } log.Info("Terminating..."); server.Stop(); policy.Stop(); manager.Stop(); db.Dispose(); log.Info("Server terminated."); } }
private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; using (Settings = new SimpleSettings("server")) { GameData = new XmlData(); var port = Settings.GetValue <int>("port", "8080"); listener = new HttpListener(); listener.Prefixes.Add("http://*:" + port + "/"); listener.Start(); listener.BeginGetContext(ListenerCallback, null); for (int i = 0; i < workers.Length; i++) { workers[i] = new Thread(Worker) { Name = "Worker " + i }; workers[i].Start(); } Console.CancelKeyPress += (sender, e) => e.Cancel = true; log.Info("Listening at port " + port + "..."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } log.Info("Terminating..."); terminating = true; listener.Stop(); queueReady.Set(); GameData.Dispose(); while (contextQueue.Count > 0) { Thread.Sleep(100); } } }
private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Settings = new SimpleSettings("wServer"); Database.Init(Settings.GetValue <string>("db_host", "nillysrealm.com"), Settings.GetValue <string>("db_port", "3306"), Settings.GetValue <string>("db_name", "rotmg"), Settings.GetValue <string>("db_user", ""), Settings.GetValue <string>("db_pass", "botmaker")); var manager = new RealmManager(); manager.Initialize(); manager.Run(); var server = new Server(Settings.GetValue <int>("port", "2050")); var policy = new PolicyServer(); policy.Start(); server.Start(); log.Info("Server initialized."); Console.CancelKeyPress += delegate { log.Info("Terminating..."); server.Stop(); policy.Stop(); //Settings.Dispose(); log.Info("Server terminated."); Thread.Sleep(500); Environment.Exit(0); }; while (true) { Thread.Sleep(500); } }
private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_server.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Settings = new SimpleSettings("server"); Database = new Database( Settings.GetValue<string>("db_host", "127.0.0.1"), Settings.GetValue<string>("db_database", "rotmgprod"), Settings.GetValue<string>("db_user", "root"), Settings.GetValue<string>("db_auth", "")); GameData = new XmlData(); ServerDomain = Settings.GetValue("serverDomain", "127.0.0.1"); ServerPort = Settings.GetValue<int>("port", "80"); InstanceId = Guid.NewGuid().ToString(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; var port = Settings.GetValue<int>("port", "80"); if (RunPreCheck(port)) { listener = new HttpListener(); listener.Prefixes.Add($"http://*:{port}/"); listener.Start(); listener.BeginGetContext(ListenerCallback, null); logger.Info($"Listening at port {port}..."); } else logger.Error($"Port {port} is occupied. Can't start listening...\nPress ESC to exit."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) ; logger.Info("Terminating..."); //To prevent a char/list account in use if //both servers are closed at the same time while (currentRequests.Count > 0) ; 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(); } }
private static void Main(string[] args) { Console.Title = "Phoenix Realms: Reborn - World Server"; XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; using (Settings = new SimpleSettings("wServer")) { var db = new Database(Settings.GetValue("conn")); var manager = new RealmManager( Settings.GetValue <int>("maxClient", "100"), Settings.GetValue <int>("tps", "10"), db); manager.Initialize(); manager.Run(); var server = new Server(manager, 2050); var policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); log.Info("Server initialized."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } log.Info("Terminating..."); server.Stop(); policy.Stop(); manager.Stop(); db.Dispose(); log.Info("Server terminated."); } }
private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_wServer.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; using (Settings = new SimpleSettings("wServer")) { new Database( Settings.GetValue("dbHost", "127.0.0.1"), Settings.GetValue("dbName", "fluffyadventure"), Settings.GetValue("dbUser", "root"), Settings.GetValue("dbPassword", "")); RealmManager manager = new RealmManager( Settings.GetValue <int>("maxClient", "100"), Settings.GetValue <int>("tps", "20")); manager.Initialize(); manager.Run(); Server server = new Server(manager, 2050); PolicyServer policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); log.Info("Server initialized."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } log.Info("Terminating..."); server.Stop(); policy.Stop(); manager.Stop(); log.Info("Server terminated."); } }
//This is set here, just in case the client SOMEHOW manages to connect before the Settings.Value is set. Which is impossible, but it's whatever. private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); System.Timers.Timer timer = new System.Timers.Timer(65 * 60 * 1000); timer.Elapsed += AutoRestart; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; using (Settings = new SimpleSettings("wServer")) { serverDatabaseConnString = Settings.GetValue("conn"); //Ugh, this should do good. :] serverTPS = Settings.GetValue <int>("tps", "5"); serverMaxClients = Settings.GetValue <int>("maxClient", "100"); manager = new RealmManager(serverMaxClients, serverTPS); manager.Initialize(); manager.Run(); var server = new Server(manager, 2050); var policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); log.Info("Server initialized."); timer.Start(); while (((uint)Console.ReadKey(true).Key) != (uint)ConsoleKey.Escape) { log.Info("Terminating..."); server.Stop(); policy.Stop(); manager.Stop(); log.Info("Server terminated."); } } }
public async Task CanLoadUsingConsulJsonConfigurationProvider() { var keyname = Guid.NewGuid().ToString(); using (var configRegistry = new ConsulRegistry(Options.Create <ConsulRegistryConfig>(new ConsulRegistryConfig() { KeyParser = new JsonKeyValueParser() }))) { var settings = new SimpleSettings { Test1 = _value1, Test2 = _value2, Nested = new SimpleNestedSettings { Test3 = _value3, Test4 = _value4 } }; await configRegistry.SetKeyJsonAsync($"org/{keyname}/Settings", settings); var config = new ConfigurationBuilder() .AddConfigurationRegistry(configRegistry) .Build(); //TODO: At the moment require this line after builder as it sets parser. Probably need to rethink this. await configRegistry.AddStaticKeyPathAsync($"org/{keyname}"); var simpleSettings = new SimpleSettings(); var configSection = config.GetSection("Settings"); configSection.Bind(simpleSettings); Assert.Equal(_value1, simpleSettings.Test1); Assert.Equal(_value2, simpleSettings.Test2); Assert.Equal(_value3, simpleSettings.Nested.Test3); Assert.Equal(_value4, simpleSettings.Nested.Test4); } }
private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_server.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Settings = new SimpleSettings("server"); Database = new Database( Settings.GetValue("dbHost", "127.0.0.1"), Settings.GetValue("dbName", "fluffyadventure"), Settings.GetValue("dbUser", "root"), Settings.GetValue("dbPassword", "")); GameData = new XmlData(); var port = Settings.GetValue <int>("port", "8080"); 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 + "..."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } Logger.Info("Terminating..."); while (currentRequests.Count > 0) { ; } listener.Stop(); GameData.Dispose(); Settings.Dispose(); }
private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Settings = new SimpleSettings("server"); Database.Init(Settings.GetValue <string>("db_host", "nillysrealm.com"), Settings.GetValue <string>("db_port", "3306"), Settings.GetValue <string>("db_name", "rotmg"), Settings.GetValue <string>("db_user", ""), Settings.GetValue <string>("db_pass", "botmaker")); var port = Settings.GetValue <int>("port", "8888"); _listener = new HttpListener(); _listener.Prefixes.Add("http://*:" + port + "/"); _listener.Start(); _listener.BeginGetContext(ListenerCallback, null); Log.Info("Listening at port " + port + "..."); Console.CancelKeyPress += delegate { Log.Info("Terminating..."); _listener.Stop(); //Settings.Dispose(); Environment.Exit(0); }; while (true) { Thread.Sleep(500); } }
static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; using (Settings = new SimpleSettings("wServer")) { var db = new Database(Settings.GetValue("conn")); RealmManager manager = new RealmManager( Settings.GetValue<int>("maxClient", "100"), Settings.GetValue<int>("tps", "20"), db); manager.Initialize(); manager.Run(); Server server = new Server(manager, 2050); PolicyServer policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); log.Info("Server initialized."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) ; log.Info("Terminating..."); server.Stop(); policy.Stop(); manager.Stop(); db.Dispose(); log.Info("Server terminated."); } }
private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; System.Timers.Timer timer = new System.Timers.Timer(45 * 60 * 1000); timer.Elapsed += AutoRestart; using (Settings = new SimpleSettings("server")) { GameData = new XmlData(); var port = Settings.GetValue <int>("port", "8080"); RequestHandler.LoadHandlers(); listener = new HttpListener(); listener.Prefixes.Add("http://+:" + port + "/"); listener.Start(); timer.Start(); listener.BeginGetContext(ListenerCallback, null); Console.CancelKeyPress += (sender, e) => e.Cancel = true; log.Info("Listening at port " + port + "..."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } log.Info("Terminating..."); listener.Stop(); GameData.Dispose(); } }
static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; using (Settings = new SimpleSettings("server")) { GameData = new XmlData(); int port = Settings.GetValue<int>("port", "8888"); listener = new HttpListener(); listener.Prefixes.Add("http://*:" + port + "/"); listener.Start(); listener.BeginGetContext(ListenerCallback, null); for (var i = 0; i < workers.Length; i++) { workers[i] = new Thread(Worker) { Name = "Worker " + i }; workers[i].Start(); } Console.CancelKeyPress += (sender, e) => e.Cancel = true; log.Info("Listening at port " + port + "..."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) ; log.Info("Terminating..."); terminating = true; listener.Stop(); queueReady.Set(); GameData.Dispose(); while (contextQueue.Count > 0) Thread.Sleep(100); } }
public async Task CanLoadUsingConsulJsonConfigurationProvider() { var keyname = Guid.NewGuid().ToString(); using (var manager = new ServiceManager("TestService")) { var settings = new SimpleSettings { Test1 = _value1, Test2 = _value2, Nested = new SimpleNestedSettings { Test3 = _value3, Test4 = _value4 } }; await manager.Config.SetKeyJsonAsync($"org/{keyname}/Settings", settings); var config = new ConfigurationBuilder() .AddJsonConsul(manager.Config) .Build(); //TODO: At the moment require this line after builder as it sets parser. Probably need to rethink this. await manager.Config.AddStaticKeyPathAsync($"org/{keyname}"); var simpleSettings = new SimpleSettings(); var configSection = config.GetSection("Settings"); configSection.Bind(simpleSettings); Assert.Equal(_value1, simpleSettings.Test1); Assert.Equal(_value2, simpleSettings.Test2); Assert.Equal(_value3, simpleSettings.Nested.Test3); Assert.Equal(_value4, simpleSettings.Nested.Test4); } }
private static void Main(string[] args) { Console.Title = "Fabiano Swagger of Doom - World Server"; try { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_wServer.config")); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.Name = "Entry"; Settings = new SimpleSettings("wServer"); new Database( Settings.GetValue<string>("db_host", "127.0.0.1"), Settings.GetValue<string>("db_database", "rotmgprod"), Settings.GetValue<string>("db_user", "root"), Settings.GetValue<string>("db_auth", "")); manager = new RealmManager( Settings.GetValue<int>("maxClients", "100"), Settings.GetValue<int>("tps", "20")); WhiteList = Settings.GetValue<bool>("whiteList", "false"); Verify = Settings.GetValue<bool>("verifyEmail", "false"); WhiteListTurnOff = Settings.GetValue<DateTime>("whitelistTurnOff"); manager.Initialize(); manager.Run(); Server server = new Server(manager); PolicyServer policy = new PolicyServer(); Console.CancelKeyPress += (sender, e) => e.Cancel = true; policy.Start(); server.Start(); if(Settings.GetValue<bool>("broadcastNews", "false") && File.Exists("news.txt")) new Thread(autoBroadcastNews).Start(); log.Info("Server initialized."); uint key = 0; while ((key = (uint)Console.ReadKey(true).Key) != (uint)ConsoleKey.Escape) { if (key == (2 | 80)) Settings.Reload(); } log.Info("Terminating..."); server.Stop(); policy.Stop(); manager.Stop(); log.Info("Server terminated."); } catch (Exception e) { log.Fatal(e); foreach (var c in manager.Clients) { c.Value.Disconnect(); } Console.ReadLine(); } }
public ISettingsProvider Register(string modId) { settings = new SimpleSettings(modId); return(Singleton <Settings> .SetInstance(this)); }