Ejemplo n.º 1
0
        public PublishedFileDetails GetPublishedFileDetails(uint appId, PublishedFileID pubFile)
        {
            var pubFileRequest = new CPublishedFile_GetDetails_Request()
            {
                appid = appId
            };

            pubFileRequest.publishedfileids.Add(pubFile);

            bool completed = false;
            PublishedFileDetails details = null;

            Action <SteamUnifiedMessages.ServiceMethodResponse> cbMethod = callback =>
            {
                completed = true;
                if (callback.Result == EResult.OK)
                {
                    var response = callback.GetDeserializedResponse <CPublishedFile_GetDetails_Response>();
                    details = response.publishedfiledetails.FirstOrDefault();
                }
                else
                {
                    throw new Exception($"EResult {(int)callback.Result} ({callback.Result}) while retrieving file details for pubfile {pubFile}.");
                }
            };

            WaitUntilCallback(() =>
            {
                callbacks.Subscribe(steamPublishedFile.SendMessage(api => api.GetDetails(pubFileRequest)), cbMethod);
            }, () => { return(completed); });

            return(details);
        }
Ejemplo n.º 2
0
        public Task <PublishedFileDetails> GetPubfileDetails(PublishedFileID pubFile)
        {
            var tsc = new TaskCompletionSource <PublishedFileDetails>();

            var pubFileRequest = new CPublishedFile_GetDetails_Request();

            pubFileRequest.publishedfileids.Add(pubFile);

            IDisposable subscription = null;
            Action <SteamUnifiedMessages.ServiceMethodResponse> cbMethod = callback =>
            {
                subscription.Dispose();
                if (callback.Result == EResult.OK)
                {
                    var response = callback.GetDeserializedResponse <CPublishedFile_GetDetails_Response>();
                    tsc.SetResult(response.publishedfiledetails[0]);
                }
                else
                {
                    tsc.SetResult(null);
                    throw new Exception($"EResult {(int)callback.Result} ({callback.Result}) while retrieving UGC id for pubfile {pubFile}.");
                }
            };

            subscription = callbacks.Subscribe(steamPublishedFile.SendMessage(api => api.GetDetails(pubFileRequest)), cbMethod);
            return(tsc.Task);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Requests details for a given published workshop file.
        /// Results are returned in a <see cref="PublishedFileDetailsCallback"/> from a <see cref="SteamClient.JobCallback&lt;T&gt;"/>.
        /// </summary>
        /// <param name="publishedFileId">The file ID being requested.</param>
        /// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="SteamClient.JobCallback&lt;T&gt;"/>.</returns>
        public JobID RequestPublishedFileDetails( PublishedFileID publishedFileId )
        {
            var request = new ClientMsgProtobuf<CMsgClientUCMGetPublishedFileDetails>( EMsg.ClientUCMGetPublishedFileDetails );
            request.SourceJobID = Client.GetNextJobID();

            request.Body.published_file_id = publishedFileId;

            Client.Send( request );

            return request.SourceJobID;
        }
Ejemplo n.º 4
0
        public CPublishedFile_GetItemInfo_Response.WorkshopItemInfo GetPubfileItemInfo(uint appId, PublishedFileID pubFile)
        {
            var pubFileRequest = new CPublishedFile_GetItemInfo_Request()
            {
                app_id = appId
            };

            pubFileRequest.workshop_items.Add(new CPublishedFile_GetItemInfo_Request.WorkshopItem()
            {
                published_file_id = pubFile
            });

            bool completed = false;

            CPublishedFile_GetItemInfo_Response.WorkshopItemInfo details = null;

            Action <SteamUnifiedMessages.ServiceMethodResponse> cbMethod = callback =>
            {
                completed = true;
                if (callback.Result == EResult.OK)
                {
                    var response = callback.GetDeserializedResponse <CPublishedFile_GetItemInfo_Response>();
                    details = response.workshop_items.FirstOrDefault();
                }
                else
                {
                    throw new Exception($"EResult {(int)callback.Result} ({callback.Result}) while retrieving UGC id for pubfile {pubFile}.");
                }
            };

            WaitUntilCallback(() =>
            {
                callbacks.Subscribe(steamPublishedFile.SendMessage(api => api.GetItemInfo(pubFileRequest)), cbMethod);
            }, () => { return(completed); });

            return(details);
        }
Ejemplo n.º 5
0
 internal File( CMsgClientUCMEnumerateUserPublishedFilesResponse.PublishedFileId file )
 {
     this.FileID = file.published_file_id;
 }
Ejemplo n.º 6
0
 public JobID RequestPublishedFileDetails( PublishedFileID publishedFileId )
 {
     return JobID.Invalid;
 }