示例#1
0
        /// <summary>
        /// Loads all necessary components and starts the server.
        /// </summary>
        public void Run()
        {
            if (_running)
            {
                throw new Exception("Server is already running.");
            }

            CliUtil.WriteHeader("Login Server", ConsoleColor.Magenta);
            CliUtil.LoadingTitle();

            this.NavigateToRoot();

            // Conf
            this.LoadConf(this.Conf = new LoginConf());

            // Database
            this.InitDatabase(this.Database = new LoginDb(), this.Conf);

            // Check if there are any updates
            this.CheckDatabaseUpdates();

            // Data
            this.LoadData(DataLoad.LoginServer, false);

            // Localization
            this.LoadLocalization(this.Conf);

            // Web API
            this.LoadWebApi();

            // Scripts
            this.LoadScripts();

            // Start
            this.Server.Start(this.Conf.Login.Port);

            CliUtil.RunningTitle();
            _running = true;

            // Commands
            var commands = new LoginConsoleCommands();

            commands.Wait();
        }
        /// <summary>
        /// Starts the server.
        /// </summary>
        public override void Run()
        {
            base.Run();

            CliUtil.WriteHeader("Login Server", ConsoleColor.Magenta);
            CliUtil.LoadingTitle();

            Log.Status("Starting Login Server...");

            // Conf
            this.LoadConf(this.Conf = new LoginConf());

            // ASD Database
            this.InitDatabase(this.ASDDatabase = new ASD(), this.Conf);

            // Redis server
            this.Redis = new Redis(this.Conf.RedisHost, this.Conf.RedisPort, this.Conf.RedisPassword);

            // Remove previously logged in accounts
            this.Redis.ResetLoggedInAccountList();

            // Packet handlers
            LoginPacketHandler.Instance.RegisterMethods();

            // Server
            var mgr = new ConnectionManager <LoginConnection>(this.Conf.Host, this.Conf.Port);

            mgr.Start();

            // Ready
            CliUtil.RunningTitle();
            Log.Status("Login Server is ready, listening on {0}.", mgr.Address);

            // Commands
            this.ConsoleCommands = new LoginConsoleCommands();
            this.ConsoleCommands.Wait();
        }