protected virtual void Initialize()
        {
            if (CommonSettings.Default.EnablePerformanceCounters)
            {
                this.InitCorePerformanceCounters();
                CustomAuthResultCounters.Initialize();
            }
            else
            {
                log.Info("Performance counters are disabled");
            }

            this.GameServers  = new GameServerContextManager(this, MasterServerSettings.Default.GSContextTTL);
            this.LoadBalancer = new LoadBalancer <GameServerContext>(Path.Combine(this.ApplicationRootPath, "LoadBalancer.config"));

            this.DefaultApplication = new GameApplication("{Default}", "{Default}", this.LoadBalancer);

            this.CustomAuthHandler = new CustomAuthHandler(new HttpRequestQueueCountersFactory());
            this.CustomAuthHandler.InitializeFromConfig();

            if (MasterServerSettings.Default.AppStatsPublishInterval > 0)
            {
                AppStats = new ApplicationStats(MasterServerSettings.Default.AppStatsPublishInterval);
            }

            //            CounterPublisher.DefaultInstance.AddStaticCounterClass(typeof(LoadBalancerCounter), this.ApplicationName);

            this.InitResolver();
        }
Example #2
0
        protected void AddNewAuthProvider(string url, string nameValuePairAsQueryString, bool rejectIfUnavailable,
                                          ClientAuthenticationType authenticationType, string instanceName)
        {
            var authService = new ClientAuthenticationQueue(
                url,
                nameValuePairAsQueryString,
                rejectIfUnavailable,
                Settings.Default.HttpRequestTimeoutMS)
            {
                MaxQueuedRequests           = Settings.Default.MaxQueuedRequests,
                MaxConcurrentRequests       = Settings.Default.MaxConcurrentRequests,
                ReconnectInterval           = TimeSpan.FromSeconds(Settings.Default.ReconnectIntervalS),
                QueueTimeout                = TimeSpan.FromSeconds(Settings.Default.QueueTimeoutS),
                MaxErrorRequests            = Settings.Default.MaxErrorRequests,
                MaxTimedOutRequests         = Settings.Default.MaxTimedOutRequests,
                MaxBackoffTimeInMiliseconds = Settings.Default.MaxBackoffTimeInMiliseconds,
                CustomData = CustomAuthResultCounters.GetInstance(instanceName)
            };

            var counters = this.httpQueueCountersFactory != null?this.httpQueueCountersFactory.Create(instanceName) : null;

            authService.SetHttpRequestQueueCounters(counters);
            this.authenticationServices.Add(authenticationType, authService);
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("Auth Provider added. provider:{0}", url);
            }
        }
Example #3
0
        protected virtual void Initialize()
        {
            if (CommonSettings.Default.EnablePerformanceCounters)
            {
                HttpQueuePerformanceCounters.Initialize();
                CustomAuthResultCounters.Initialize();
            }
            else
            {
                log.Info("Performance counters are disabled");
            }

            this.GameServers  = new GameServerCollection();
            this.LoadBalancer = new LoadBalancer <IncomingGameServerPeer>(Path.Combine(this.ApplicationRootPath, "LoadBalancer.config"));

            this.DefaultApplication = new GameApplication("{Default}", "{Default}", this.LoadBalancer);

            this.CustomAuthHandler = new CustomAuthHandler(new HttpRequestQueueCountersFactory());
            this.CustomAuthHandler.InitializeFromConfig();

            if (MasterServerSettings.Default.AppStatsPublishInterval > 0)
            {
                AppStats = new ApplicationStats(MasterServerSettings.Default.AppStatsPublishInterval);
            }

            this.InitResolver();
        }
Example #4
0
        protected virtual void Initialize()
        {
            WebRequest.DefaultWebProxy = null;

            log.Info("Initializing ...");

            log.Info("ServicePointManager.DefaultConnectionLimit=" + ServicePointManager.DefaultConnectionLimit);

            this.SetupTokenCreator();

            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;

            Protocol.RegisterTypeMapper(new UnknownTypeMapper());

            if (Settings.Default.EnablePerformanceCounters)
            {
                this.InitCorePerformanceCounters();
                CustomAuthResultCounters.Initialize();
            }
            else
            {
                log.Info("Performance counters are disabled");
            }

            // load nameserver config & initialize file watcher
            if (!string.IsNullOrEmpty(this.ApplicationRootPath) && Directory.Exists(this.ApplicationRootPath))
            {
                this.fileWatcher                     = new FileSystemWatcher(this.ApplicationRootPath, Settings.Default.NameServerConfig);
                this.fileWatcher.Changed            += this.ConfigFileChanged;
                this.fileWatcher.Created            += this.ConfigFileChanged;
                this.fileWatcher.Renamed            += this.ConfigFileChanged;
                this.fileWatcher.EnableRaisingEvents = true;
            }

            string message;

            if (!this.ReadNameServerConfigurationFile(out message))
            {
                log.Error(message);
                throw new ConfigurationException(message);
            }

            this.CustomAuthHandler = new CustomAuthHandler(new HttpRequestQueueCountersFactory());
            this.CustomAuthHandler.InitializeFromConfig();
        }