private void ProfileServices()
        {
            this.networkCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(new[] { serverLifetime.ApplicationStopping });

            asyncLoopFactory.Run("Price.ProfileCheckService", async token =>
            {
                try
                {
                    if (xServer.Stats.TierLevel == Tier.TierLevel.Two && networkFeatures.IsServerReady())
                    {
                        await CheckReservedProfiles(this.networkCancellationTokenSource.Token).ConfigureAwait(false);
                    }
                }
                catch (Exception ex)
                {
                    this.logger.LogError("Exception: {0}", ex);
                    this.logger.LogTrace("(-)[UNHANDLED_EXCEPTION_PROFILE_CHECK]");
                    throw;
                }
            },
                                 this.networkCancellationTokenSource.Token,
                                 repeatEvery: TimeSpan.FromSeconds(this.updateProfileReservationsSeconds),
                                 startAfter: TimeSpans.TenSeconds);

            asyncLoopFactory.Run("Price.ProfileRelayService", async token =>
            {
                try
                {
                    if (xServer.Stats.TierLevel == Tier.TierLevel.Two && networkFeatures.IsServerReady())
                    {
                        await RelayProfiles(this.networkCancellationTokenSource.Token).ConfigureAwait(false);
                    }
                }
                catch (Exception ex)
                {
                    this.logger.LogError("Exception: {0}", ex);
                    this.logger.LogTrace("(-)[UNHANDLED_EXCEPTION_PROFILE_RELAY]");
                    throw;
                }
            },
                                 this.networkCancellationTokenSource.Token,
                                 repeatEvery: TimeSpan.FromSeconds(this.relayProfileSeconds),
                                 startAfter: TimeSpans.TenSeconds);

            asyncLoopFactory.Run("Price.ProfileSyncService", async token =>
            {
                try
                {
                    if (networkFeatures.IsServerReady())
                    {
                        await SyncProfiles(this.networkCancellationTokenSource.Token).ConfigureAwait(false);
                    }
                }
                catch (Exception ex)
                {
                    this.logger.LogError("Exception: {0}", ex);
                    this.logger.LogTrace("(-)[UNHANDLED_EXCEPTION_PROFILE_SYNC]");
                    throw;
                }
            },
                                 this.networkCancellationTokenSource.Token,
                                 repeatEvery: TimeSpan.FromSeconds(this.syncProfileSeconds),
                                 startAfter: TimeSpans.TenSeconds);
        }
Exemple #2
0
        private void PriceLockServices()
        {
            this.networkCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(new[] { serverLifetime.ApplicationStopping });

            asyncLoopFactory.Run("Price.MyMonitor", async token =>
            {
                try
                {
                    if (xServer.Stats.TierLevel == Tier.TierLevel.Three)
                    {
                        await UpdateMyPriceList(this.networkCancellationTokenSource.Token).ConfigureAwait(false);
                    }
                }
                catch (Exception ex)
                {
                    this.logger.LogError("Exception: {0}", ex);
                    this.logger.LogTrace("(-)[UNHANDLED_EXCEPTION_MY_PRICE]");
                    throw;
                }
            },
                                 this.networkCancellationTokenSource.Token,
                                 repeatEvery: TimeSpan.FromSeconds(this.updateMyPriceSeconds),
                                 startAfter: TimeSpans.TenSeconds);

            asyncLoopFactory.Run("Price.NetworkMonitor", async token =>
            {
                try
                {
                    if (xServer.Stats.TierLevel == Tier.TierLevel.Three)
                    {
                        await UpdateNetworkPriceList(this.networkCancellationTokenSource.Token).ConfigureAwait(false);
                    }
                }
                catch (Exception ex)
                {
                    this.logger.LogError("Exception: {0}", ex);
                    this.logger.LogTrace("(-)[UNHANDLED_EXCEPTION_NETWORK_PRICE]");
                    throw;
                }
            },
                                 this.networkCancellationTokenSource.Token,
                                 repeatEvery: TimeSpan.FromSeconds(this.updateNetworkPriceSeconds),
                                 startAfter: TimeSpans.TenSeconds);

            asyncLoopFactory.Run("Price.PriceLockMonitor", async token =>
            {
                try
                {
                    if (xServer.Stats.TierLevel == Tier.TierLevel.Three && networkFeatures.IsServerReady())
                    {
                        await PriceLockChecks(this.networkCancellationTokenSource.Token).ConfigureAwait(false);
                    }
                }
                catch (Exception ex)
                {
                    this.logger.LogError("Exception: {0}", ex);
                    this.logger.LogTrace("(-)[UNHANDLED_EXCEPTION_NETWORK_PRICE]");
                    throw;
                }
            },
                                 this.networkCancellationTokenSource.Token,
                                 repeatEvery: TimeSpans.Minute,
                                 startAfter: TimeSpans.TenSeconds);
        }