Use SteamContent.GetServersForSteamPipe

pull/278/head
Pavel Djundik 4 years ago
parent bef429908a
commit e915870db7

@ -2,10 +2,8 @@ using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using SteamKit2;
using SteamKit2.CDN; using SteamKit2.CDN;
namespace DepotDownloader namespace DepotDownloader
@ -52,14 +50,10 @@ namespace DepotDownloader
} }
private async Task<IReadOnlyCollection<Server>> FetchBootstrapServerListAsync() private async Task<IReadOnlyCollection<Server>> FetchBootstrapServerListAsync()
{
var backoffDelay = 0;
while (!shutdownToken.IsCancellationRequested)
{ {
try try
{ {
var cdnServers = await ContentServerDirectoryService.LoadAsync(this.steamSession.steamClient.Configuration, ContentDownloader.Config.CellID, shutdownToken.Token); var cdnServers = await this.steamSession.steamContent.GetServersForSteamPipe();
if (cdnServers != null) if (cdnServers != null)
{ {
return cdnServers; return cdnServers;
@ -68,14 +62,6 @@ namespace DepotDownloader
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine("Failed to retrieve content server list: {0}", ex.Message); 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; return null;

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@ -40,6 +40,7 @@ namespace DepotDownloader
public SteamClient steamClient; public SteamClient steamClient;
public SteamUser steamUser; public SteamUser steamUser;
public SteamContent steamContent;
readonly SteamApps steamApps; readonly SteamApps steamApps;
readonly SteamCloud steamCloud; readonly SteamCloud steamCloud;
readonly SteamUnifiedMessages.UnifiedService<IPublishedFile> steamPublishedFile; readonly SteamUnifiedMessages.UnifiedService<IPublishedFile> steamPublishedFile;
@ -101,6 +102,7 @@ namespace DepotDownloader
this.steamCloud = this.steamClient.GetHandler<SteamCloud>(); this.steamCloud = this.steamClient.GetHandler<SteamCloud>();
var steamUnifiedMessages = this.steamClient.GetHandler<SteamUnifiedMessages>(); var steamUnifiedMessages = this.steamClient.GetHandler<SteamUnifiedMessages>();
this.steamPublishedFile = steamUnifiedMessages.CreateService<IPublishedFile>(); this.steamPublishedFile = steamUnifiedMessages.CreateService<IPublishedFile>();
this.steamContent = this.steamClient.GetHandler<SteamContent>();
this.callbacks = new CallbackManager(this.steamClient); this.callbacks = new CallbackManager(this.steamClient);

Loading…
Cancel
Save