Ejemplo n.º 1
0
        private void Start()
        {
            _logger.Debug("Environment:");
            _logger.Debug("CurrentDirectory: {0}", Environment.CurrentDirectory);
            _logger.Debug("ApplicationDirectory: {0}", Utils.ApplicationDirectory());
            _logger.Debug("RelativeApplicationDirectory: {0}", Utils.RelativeApplicationDirectory());
            _logger.Debug("OS: {0}", Environment.OSVersion);
            _logger.Debug(".NET: {0}", Environment.Version);
            _logger.Debug("x64: {0}", Environment.Is64BitProcess);
            _logger.Debug("Processors: {0}", Environment.ProcessorCount);
            _logger.Debug("---");

            SettingsProvider  settingsProvider  = new SettingsProvider();
            SettingsContainer settingsContainer = settingsProvider.Load <SettingsContainer>(LocalSettingsContainer);

            if (settingsContainer == null)
            {
                settingsContainer = settingsProvider.CreateLocalSettings();
                settingsProvider.Save(settingsContainer, LocalSettingsContainer);
                _logger.Info("No settings found ({0}), creating new one.", LocalSettingsContainer);
            }
            else
            {
                _logger.Info("Loaded settings configuration ({0}).", LocalSettingsContainer);
            }

            List <EzServer> servers = new List <EzServer>();

            if (_versionType == VersionType.Reboot13)
            {
                foreach (WorldServerSettings serverSettings in settingsContainer.WorldSettingsList)
                {
                    servers.Add(new Server.Reboot13.WorldServer(settingsContainer, serverSettings));
                }
                servers.Add(new Server.Reboot13.LoginServer(settingsContainer));
            }
            else if (_versionType == VersionType.Solista)
            {
                foreach (WorldServerSettings serverSettings in settingsContainer.WorldSettingsList)
                {
                    servers.Add(new Server.Solista.WorldServer(settingsContainer, serverSettings));
                }
                servers.Add(new Server.Solista.LoginServer(settingsContainer));
            }
            else
            {
                Console.WriteLine("Invalid parameter.");
                return;
            }

            foreach (EzServer server in servers)
            {
                server.Start();
            }

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
            foreach (EzServer server in servers)
            {
                server.Stop();
            }
        }