Implement package tokens (#103)

pull/115/head
Pavel Djundik 6 years ago committed by GitHub
parent 2ca1f3e8e6
commit 05d6da9662
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,7 +5,7 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="protobuf-net" Version="2.4.4" /> <PackageReference Include="protobuf-net" Version="2.4.6" />
<PackageReference Include="SteamKit2" Version="2.3.0-Beta.1" /> <PackageReference Include="SteamKit2" Version="2.3.0-beta.2" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -1,5 +1,5 @@
using SteamKit2; using SteamKit2;
using SteamKit2.Unified.Internal; using SteamKit2.Internal;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
@ -33,6 +33,7 @@ namespace DepotDownloader
public Dictionary<uint, byte[]> AppTickets { get; private set; } public Dictionary<uint, byte[]> AppTickets { get; private set; }
public Dictionary<uint, ulong> AppTokens { get; private set; } public Dictionary<uint, ulong> AppTokens { get; private set; }
public Dictionary<uint, ulong> PackageTokens { get; private set; }
public Dictionary<uint, byte[]> DepotKeys { get; private set; } public Dictionary<uint, byte[]> DepotKeys { get; private set; }
public ConcurrentDictionary<string, TaskCompletionSource<SteamApps.CDNAuthTokenCallback>> CDNAuthTokens { get; private set; } public ConcurrentDictionary<string, TaskCompletionSource<SteamApps.CDNAuthTokenCallback>> CDNAuthTokens { get; private set; }
public Dictionary<uint, SteamApps.PICSProductInfoCallback.PICSProductInfo> AppInfo { get; private set; } public Dictionary<uint, SteamApps.PICSProductInfoCallback.PICSProductInfo> AppInfo { get; private set; }
@ -82,6 +83,7 @@ namespace DepotDownloader
this.AppTickets = new Dictionary<uint, byte[]>(); this.AppTickets = new Dictionary<uint, byte[]>();
this.AppTokens = new Dictionary<uint, ulong>(); this.AppTokens = new Dictionary<uint, ulong>();
this.PackageTokens = new Dictionary<uint, ulong>();
this.DepotKeys = new Dictionary<uint, byte[]>(); this.DepotKeys = new Dictionary<uint, byte[]>();
this.CDNAuthTokens = new ConcurrentDictionary<string, TaskCompletionSource<SteamApps.CDNAuthTokenCallback>>(); this.CDNAuthTokens = new ConcurrentDictionary<string, TaskCompletionSource<SteamApps.CDNAuthTokenCallback>>();
this.AppInfo = new Dictionary<uint, SteamApps.PICSProductInfoCallback.PICSProductInfo>(); this.AppInfo = new Dictionary<uint, SteamApps.PICSProductInfoCallback.PICSProductInfo>();
@ -236,9 +238,24 @@ namespace DepotDownloader
} }
}; };
var packageRequests = new List<SteamApps.PICSRequest>();
foreach ( var package in packages )
{
var request = new SteamApps.PICSRequest( package );
if ( PackageTokens.TryGetValue( package, out var token ) )
{
request.AccessToken = token;
request.Public = false;
}
packageRequests.Add( request );
}
WaitUntilCallback( () => WaitUntilCallback( () =>
{ {
callbacks.Subscribe( steamApps.PICSGetProductInfo( new List<uint>(), packages ), cbMethod ); callbacks.Subscribe( steamApps.PICSGetProductInfo( new List<SteamApps.PICSRequest>(), packageRequests ), cbMethod );
}, () => { return completed; } ); }, () => { return completed; } );
} }
@ -627,6 +644,14 @@ namespace DepotDownloader
Console.WriteLine( "Got {0} licenses for account!", licenseList.LicenseList.Count ); Console.WriteLine( "Got {0} licenses for account!", licenseList.LicenseList.Count );
Licenses = licenseList.LicenseList; Licenses = licenseList.LicenseList;
foreach ( var license in licenseList.LicenseList )
{
if ( license.AccessToken > 0 )
{
PackageTokens.Add( license.PackageID, license.AccessToken );
}
}
} }
private void UpdateMachineAuthCallback( SteamUser.UpdateMachineAuthCallback machineAuth ) private void UpdateMachineAuthCallback( SteamUser.UpdateMachineAuthCallback machineAuth )

Loading…
Cancel
Save