示例#1
0
 private static void DownloadAndConfirm(PublishedFile pf)
 {
     if (!SteamUGC.DownloadItem(pf.Pid, true))
     {
         throw new InvalidOperationException("Failed to initiate download");
     }
 }
示例#2
0
 private void Bla(PublishedFile pf)
 {
     var   s = UpdateAndConfirm(pf);
     ulong bytes;
     ulong bytesTotal;
     var   p = SteamUGC.GetItemUpdateProgress(s, out bytes, out bytesTotal);
 }
示例#3
0
 private IObservable <Unit> CreateTimeoutSource(PublishedFile pf)
 => ObserveDownloadInfo(pf.Pid)
 .Throttle(TimeSpan.FromMinutes(2))
 .Do(x => MainLog.Logger.Info($"Reached timeout for {pf}"))
 .Do(x => {
     throw new TimeoutException(
         "Did not receive download progress info from Steam for over 60 seconds");
 })
 .Void();
示例#4
0
        private async Task PerformDownload(PublishedFile pf, Action <DownloadInfo> pCb, CancellationToken cancelToken)
        {
            var readySignal = CreateReadySignal(pf, cancelToken);
            // in case we get a result before we would be waiting for it..
            var readySignalTask = readySignal.ToTask(cancelToken);

            DownloadAndConfirm(pf);
            using (pCb == null ? null : ProcessDownloadInfo(pf, pCb, readySignal))
                await readySignalTask.ConfigureAwait(false);
        }
示例#5
0
 public Task Download(PublishedFile pf, Action <long?, double> progressAction = null,
                      CancellationToken cancelToken = default(CancellationToken))
 {
     if (progressAction != null)
     {
         HandleProgress(progressAction);
     }
     return
         (PerformDownload(pf, progressAction != null ? HandleProgress(progressAction) : null, cancelToken));
 }
示例#6
0
        private static UGCUpdateHandle_t UpdateAndConfirm(PublishedFile pf)
        {
            var r = SteamUGC.StartItemUpdate(pf.Aid, pf.Pid);

            if (r == null)
            {
                throw new InvalidOperationException("Failed to initiate update");
            }
            return(r);
        }
        private async Task PostMessageAboutPublishedFile(long fileId, string url, SocketMessage message)
        {
            //string request = $@"https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1/?key={Android.ApiKey}&itemcount=1&publishedfileids%5B0%5D={fileId}";
            string request = $@"https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1";
            SteamApiResponseDeep response;

            try
            {
                var data = new Dictionary <string, string> {
                    { "key", Android.ApiKey },
                    { "itemcount", "1" },
                    { "publishedfileids[0]", fileId.ToString() },
                };
                var rawResponse = await Utils.HttpPost(request, data);

                response = JsonConvert.DeserializeObject <SteamApiResponse>(rawResponse).response;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return;
            }

            if (response.resultcount < 1)
            {
                Console.WriteLine($"Workshop resultcount for {fileId} is {response.resultcount}");
                return;
            }

            PublishedFile publishedFile = response.publishedfiledetails[0];

            if (publishedFile.creator_app_id != 1118200) // is this even a PPG workshop item?
            {
                Console.WriteLine($"{fileId} isnt actually a PPG item");
            }

            EmbedBuilder embed = new EmbedBuilder();

            embed.Title        = publishedFile.title;
            embed.ThumbnailUrl = publishedFile.preview_url;
            embed.Url          = url;
            embed.Color        = new Color(0x1b2838);
            embed.Description  = publishedFile.description;

            await message.Channel.SendMessageAsync(embed : embed.Build());
        }
示例#8
0
 private IObservable <Unit> CreateInstalledFileCompletionSource(PublishedFile pf, CancellationToken cancelToken)
 => ObserveInstalledFileForApp(pf, cancelToken)
 .Do(x => MainLog.Logger.Info($"Received InstalledFile event for {pf}"))
 .Void();
示例#9
0
 private IObservable <Unit> CreateDownloadItemResultCompletionSource(PublishedFile pf,
                                                                     CancellationToken cancelToken)
 => ObserveDownloadItemResultForApp(pf, cancelToken)
 .Do(x => MainLog.Logger.Info($"Received DownloadItemResult event for {pf}"))
 .Do(x => _api.ConfirmResult(x.m_eResult))
 .Void();
示例#10
0
 // Generally we get the InstalledItem event first, and very shortly after we get the DownloadItemResult
 private IObservable <Unit> CreateReadySignal(PublishedFile pf, CancellationToken cancelToken)
 => CreateDownloadItemResultCompletionSource(pf, cancelToken)
 .Merge(CreateInstalledFileCompletionSource(pf, cancelToken), _api.Scheduler)
 //.Merge(CreateProgressCompletionSource(pf), _api.Scheduler)
 .Merge(CreateTimeoutSource(pf), _api.Scheduler)
 .Take(1);
示例#11
0
 private IObservable <ItemInstalled_t> ObserveInstalledFileForApp(PublishedFile pf, CancellationToken cancelToken)
 => ObserveInstalledFileForApp(pf.Aid, pf.Pid, cancelToken);
示例#12
0
        // however since we probably already unsubscribe before completion it doesn't really help :)

        private IObservable <DownloadItemResult_t> ObserveDownloadItemResultForApp(PublishedFile pf,
                                                                                   CancellationToken cancelToken) =>
        ObserveDownloadItemResultForApp(pf.Aid, pf.Pid, cancelToken);
示例#13
0
 private IDisposable ProcessDownloadInfo(PublishedFile pf, Action <DownloadInfo> pCb,
                                         IObservable <Unit> readySignal) => ProcessDownloadInfo(pf.Pid, pCb, readySignal);
 private static UGCUpdateHandle_t UpdateAndConfirm(PublishedFile pf) {
     var r = SteamUGC.StartItemUpdate(pf.Aid, pf.Pid);
     if (r == null)
         throw new InvalidOperationException("Failed to initiate update");
     return r;
 }
 private void Bla(PublishedFile pf) {
     var s = UpdateAndConfirm(pf);
     ulong bytes;
     ulong bytesTotal;
     var p = SteamUGC.GetItemUpdateProgress(s, out bytes, out bytesTotal);
 }