Example #1
0
        private async Task <IReadOnlyCollection <CDNClient.Server> > FetchBootstrapServerListAsync()
        {
            var backoffDelay = 0;

            while (!shutdownToken.IsCancellationRequested)
            {
                try
                {
                    var cdnServers = await ContentServerDirectoryService.LoadAsync(this.steamSession.Client.Configuration, ContentDownloader.Config.CellID, shutdownToken.Token);

                    if (cdnServers != null)
                    {
                        return(cdnServers);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Failed to retrieve content server list: {0}", ex.Message);

                    if (ex is SteamKitWebRequestException e && e.StatusCode == (HttpStatusCode)429)
                    {
                        // If we're being throttled, add a delay to the next request
                        backoffDelay = Math.Min(5, ++backoffDelay);
                        await Task.Delay(TimeSpan.FromSeconds(backoffDelay));
                    }
                }
            }

            return(null);
        }
        private async Task <IReadOnlyCollection <CDNClient.Server> > GetServerListAsync()
        {
            int throttleDelay = 0;

            while (!_cancellationTokenSource.IsCancellationRequested)
            {
                await Task.Delay(TimeSpan.FromSeconds(1), _cancellationTokenSource.Token);

                try
                {
                    var cdnServers = await ContentServerDirectoryService.LoadAsync(
                        _steamContentClient.SteamClient.InternalClient.Configuration,
                        (int)_steamContentClient.SteamClient.SuggestedCellId,
                        _cancellationTokenSource.Token);

                    if (cdnServers == null)
                    {
                        continue;
                    }

                    return(cdnServers);
                }
                catch (Exception ex)
                {
                    if (ex is SteamKitWebRequestException requestEx && requestEx.StatusCode == System.Net.HttpStatusCode.TooManyRequests)
                    {
                        throttleDelay += 5;

                        await Task.Delay(TimeSpan.FromSeconds(throttleDelay), _cancellationTokenSource.Token);
                    }
                }
            }

            return(new List <CDNClient.Server>());
        }
        private async Task <IReadOnlyCollection <CDNClient.Server> > FetchBootstrapServerListAsync()
        {
            while (!shutdownToken.IsCancellationRequested)
            {
                try
                {
                    var cdnServers = await ContentServerDirectoryService.LoadAsync(this.steamSession.steamClient.Configuration, ContentDownloader.Config.CellID, shutdownToken.Token);

                    if (cdnServers != null)
                    {
                        return(cdnServers);
                    }
                }
                catch (Exception ex)
                {
                    DebugLog.WriteLine("CDNClientPool", "Failed to retrieve content server list: " + ex.Message);
                }
            }

            return(null);
        }
Example #4
0
        public async Task <IReadOnlyCollection <CDNClient.Server> > FetchServerList()
        {
            while (!_cancellation.IsCancellationRequested)
            {
                try
                {
                    var cdnServers =
                        await ContentServerDirectoryService.LoadAsync(_client.Configuration, _cancellation.Token);

                    if (cdnServers != null)
                    {
                        return(cdnServers);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Failed to grab content server list");
                }
            }

            return(null);
        }
Example #5
0
        private async Task <IReadOnlyCollection <CDNClient.Server> > FetchBootstrapServerListAsync()
        {
            while (!shutdownToken.IsCancellationRequested)
            {
                try
                {
                    var cdnServers = await ContentServerDirectoryService.LoadAsync(
                        ContentDownloader.Steam3.steamClient.Configuration,
                        SteamDepotDownloader_GUI.Program.UsrConfig.CellID,
                        shutdownToken.Token);

                    if (cdnServers != null)
                    {
                        return(cdnServers);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Failed to retrieve content server list: {0}", ex.Message);
                }
            }

            return(null);
        }