Ejemplo n.º 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();
        }
Ejemplo n.º 2
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();
            }
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
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);
                }
            }
        }
Ejemplo n.º 5
0
        private static void Main(string[] args)
        {
            XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net_server.config"));

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

            using (Settings = new Settings("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", "80");

                    listener = new HttpListener();
                    listener.Prefixes.Add($"http://*:80/");
                    listener.Start();

                    listener.BeginGetContext(ListenerCallback, null);
                    Console.CancelKeyPress += (sender, e) => e.Cancel = true;
                    Logger.Info("Listening at port " + 80 + "...");

                    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();
                }
        }
Ejemplo n.º 6
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();
                }
        }
Ejemplo n.º 7
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();
        }
Ejemplo n.º 8
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();
            }
        }