Example #1
0
        public SteamContentClient(Core.SteamClient steamClient,
                                  SteamContentServerQualityProvider steamContentServerQualityProvider = null,
                                  int maxConcurrentDownloadsPerTask = 10,
                                  ulong chunkBufferSize             = 3221225472,
                                  double bufferUsageThreshold       = 1)
        {
            SteamClient = steamClient;
            _steamContentServerQualityProvider = steamContentServerQualityProvider ?? new SteamContentServerQualityNoMemoryProvider();
            SteamUnifiedMessagesService        = SteamClient.InternalClient.GetHandler <SteamKit.SteamUnifiedMessages>();
            PublishedFileService          = SteamUnifiedMessagesService.CreateService <SteamKit.Unified.Internal.IPublishedFile>();
            SteamCdnServerPool            = new SteamCdnServerPool(this, _steamContentServerQualityProvider);
            MaxConcurrentDownloadsPerTask = maxConcurrentDownloadsPerTask;
            ChunkBufferSize      = chunkBufferSize;
            BufferUsageThreshold = bufferUsageThreshold;
            SteamApps            = SteamClient.InternalClient.GetHandler <SteamKit.SteamApps>();
            SteamUser            = SteamClient.InternalClient.GetHandler <SteamKit.SteamUser>();

            _cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(SteamClient.CancellationToken);
        }
Example #2
0
        public async Task <Manifest> GetManifestAsync(AppId appId, DepotId depotId, ManifestId manifestId, CancellationToken cancellationToken = default)
        {
            await SteamClient.AwaitReadyAsync(cancellationToken);

            Exception lastEx = null;

            for (int i = 0; i < 30; i++)
            {
                SteamCdnClient steamCdnClient;

                try
                {
                    steamCdnClient = await SteamCdnServerPool.GetClientAsync();

                    //await cdnClientWrapper.CdnClient.AuthenticateDepotAsync(depotId);

                    var manifest = await steamCdnClient.DownloadManifestAsync(appId, depotId, manifestId);

                    if (manifest.FilenamesEncrypted)
                    {
                        var depotKey = await steamCdnClient.GetDepotKeyAsync(depotId, appId);

                        manifest.DecryptFilenames(depotKey);
                    }

                    return(manifest);
                }
                catch (SteamDepotAccessDeniedException)
                {
                    throw;
                }
                catch (HttpRequestException ex)
                {
                    lastEx = ex;
                }
                catch (Exception ex)
                {
                    lastEx = ex;
                }
            }

            throw new SteamManifestDownloadException(lastEx);
        }
Example #3
0
        public async Task <Manifest> GetManifestAsync(AppId appId, DepotId depotId, ManifestId manifestId, CancellationToken cancellationToken = default)
        {
            await SteamClient.AwaitReadyAsync(cancellationToken);

            var pool = new SteamCdnServerPool(this, appId);

            try
            {
                var server = await pool.GetServerAsync(cancellationToken);

                var depotKey = await GetDepotKeyAsync(depotId, appId);

                var cdnKey = await pool.AuthenticateWithServerAsync(depotId, server);

                var manifest = await pool.CdnClient.DownloadManifestAsync(depotId, manifestId, server, cdnKey, depotKey, proxyServer : null);


                if (manifest.FilenamesEncrypted)
                {
                    manifest.DecryptFilenames(depotKey);
                }

                pool.ReturnServer(server, isFaulty: false);

                return(manifest);
            }
            catch (SteamDepotAccessDeniedException)
            {
                throw;
            }
            catch (HttpRequestException ex)
            {
                throw new SteamManifestDownloadException(ex);
            }
            catch (Exception ex)
            {
                throw new SteamManifestDownloadException(ex);
            }
        }