示例#1
0
        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();
        }
示例#2
0
        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();
            }
        }
示例#3
0
        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();
            }
        }
示例#4
0
        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();
        }
示例#5
0
文件: Program.cs 项目: ethus3h/LR-v2
        public static void SendEmail(MailMessage message, bool enableSsl = true)
        {
            SmtpClient client = new SmtpClient
            {
                Host                  = Settings.GetValue <string>("smtpHost", "smtp.gmail.com"),
                Port                  = Settings.GetValue <int>("smtpPort", "587"),
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                EnableSsl             = true,
                Credentials           =
                    new NetworkCredential(Settings.GetValue <string>("serverEmail"),
                                          Settings.GetValue <string>("serverEmailPassword"))
            };

            client.Send(message);
        }
示例#6
0
        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.");
                }
        }
        //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.");
                }
            }
        }
示例#8
0
        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.");
            }
        }
示例#10
0
        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", "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();
        }
示例#11
0
        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();
        }
示例#12
0
        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.");
            }
        }
示例#13
0
        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);
        }
示例#14
0
        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);
                }
            }
        }
示例#15
0
        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);
            }
        }
示例#16
0
        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();
            }
        }
示例#17
0
        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);
            }
        }
示例#18
0
        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.");
            }
        }
示例#19
0
        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);
            }
        }
示例#20
0
 public static bool IsDebugOn()
 {
     return(Settings.GetValue <bool>("debugMode", "false"));
 }
示例#21
0
        private static void Main(string[] args)
        {
            Console.Title = "FSOD";
            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.");

                foreach (var type in typeof(World).Assembly.GetTypes())
                {
                    if (type.IsAbstract || !typeof(World).IsAssignableFrom(type))
                    {
                        continue;
                    }
                    if (type.GetConstructors().First().GetParameters().Length > 0)
                    {
                        continue;
                    }
                    var world = (World)type.Assembly.CreateInstance(type.FullName);
                    if (world == null)
                    {
                        log.Warn($"Cant make World {type.Name}");
                    }
                    if (world?.Difficulty == -1)
                    {
                        log.Warn($"World {type.Name} has the default difficulty (-1)");
                    }
                    world?.Dispose();
                }

                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();
            }
        }
示例#22
0
        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();
            }
        }
示例#23
0
 public T GetValue <T>(string key, string def = null)
 {
     return(settings.GetValue <T>(key, def));
 }
示例#24
0
文件: Program.cs 项目: ethus3h/LR-v2
        private static void Main(string[] args)
        {
            Console.Title = "wServer";
            try
            {
                XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_wServer.config"));

                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                Thread.CurrentThread.Name           = "Entry";

                Settings = new SimpleSettings("wServer");
                new Database();

                manager = new RealmManager(
                    Settings.GetValue <int>("maxClients", "50"),
                    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();
                new Thread(AutoNotify).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();
            }
        }
示例#25
0
文件: Program.cs 项目: Bog624s/Rotux
        private static void Main(string[] args)
        {
            Console.Title = "Rotux - 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");
                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();
                }
                Console.WriteLine("Server initialized.");

                uint key = 0;
                while ((key = (uint)Console.ReadKey(true).Key) != (uint)ConsoleKey.Escape)
                {
                    if (key == (2 | 80))
                    {
                        Settings.Reload();
                    }
                }

                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();
                }
                Console.ReadLine();
            }
        }
示例#26
0
        private static WsServer PrepareWsServer(SimpleSettings settings)
        {
            var port = int.Parse(settings.GetValue("ws-port"));

            return(new WsServer(port));
        }