Example #1
0
        /// <summary>
        /// Request a list of files stored in the cloudfor a target App Id
        /// Results are returned in a <see cref="DepotKeyCallback"/> callback.
        /// The returned <see cref="AsyncJob{T}"/> can also be awaited to retrieve the callback result.
        /// </summary>
        /// <param name="appid">The AppID to request the file list for.</param>
        /// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="DepotKeyCallback"/>.</returns>
        public AsyncJob <ClientBeginFileUploadCallback> RequestFileUpload(uint appID, string fileName, byte[] fileData, bool compress = false)
        {
            byte[] compressedData = compress ? ZipUtil.Compress(fileData) : fileData;

            var request = new ServiceCallMsgProtobuf <CCloud_ClientBeginFileUpload_Request>(EMsg.ServiceMethodCallFromClient);

            request.SourceJobID = Client.GetNextJobID();

            request.Body.appid          = appID;
            request.Body.is_shared_file = false;
            request.Body.can_encrypt    = true;
            request.Body.filename       = fileName;
            request.Body.file_size      = (uint)compressedData.Length;
            request.Body.raw_file_size  = (uint)fileData.Length;
            request.Body.file_sha       = CryptoHelper.SHAHash(fileData);
            request.Body.time_stamp     = DateUtils.DateTimeToUnixTime(DateTime.UtcNow);
            request.TargetJobName       = SteamCloudServiceJobConstants.ClientBeginFileUpload;

            lock (_clientBeginFileUploadJobs)
            {
                _clientBeginFileUploadJobs.Add(request.SourceJobID);
            }

            Client.Send(request);

            return(new AsyncJob <ClientBeginFileUploadCallback>(Client, request.SourceJobID));
        }
Example #2
0
        /// <summary>
        /// Request a list of files stored in the cloudfor a target App Id
        /// Results are returned in a <see cref="DepotKeyCallback"/> callback.
        /// The returned <see cref="AsyncJob{T}"/> can also be awaited to retrieve the callback result.
        /// </summary>
        /// <param name="appid">The AppID to request the file list for.</param>
        /// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="DepotKeyCallback"/>.</returns>
        public AsyncJob <ClientFileDownloadCallback> ClientFileDownload(uint appid, string fileName)
        {
            var request = new ServiceCallMsgProtobuf <CCloud_ClientFileDownload_Request>(EMsg.ServiceMethodCallFromClient);

            request.SourceJobID = Client.GetNextJobID();

            request.Body.appid    = appid;
            request.Body.filename = fileName;
            request.TargetJobName = SteamCloudServiceJobConstants.ClientFileDownload;

            lock (_clientFileDownloadJobs)
            {
                _clientFileDownloadJobs.Add(request.SourceJobID);
            }

            Client.Send(request);

            return(new AsyncJob <ClientFileDownloadCallback>(Client, request.SourceJobID));
        }
Example #3
0
        /// <summary>
        /// Request a list of files stored in the cloudfor a target App Id
        /// Results are returned in a <see cref="DepotKeyCallback"/> callback.
        /// The returned <see cref="AsyncJob{T}"/> can also be awaited to retrieve the callback result.
        /// </summary>
        /// <param name="appid">The AppID to request the file list for.</param>
        /// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="DepotKeyCallback"/>.</returns>
        public AsyncJob <ClientCommitFileUploadCallback> CommitFileUpload(uint appID, string fileName, byte[] fileData, bool succeeded = false)
        {
            var request = new ServiceCallMsgProtobuf <CCloud_ClientCommitFileUpload_Request>(EMsg.ServiceMethodCallFromClient);

            request.SourceJobID = Client.GetNextJobID();

            request.Body.appid = appID;
            request.Body.transfer_succeeded = succeeded;
            request.Body.filename           = fileName;
            request.Body.file_sha           = CryptoHelper.SHAHash(fileData);
            request.TargetJobName           = SteamCloudServiceJobConstants.ClientCommitFileUpload;

            lock (_clientCommitFileJobs)
            {
                _clientCommitFileJobs.Add(request.SourceJobID);
            }

            Client.Send(request);

            return(new AsyncJob <ClientCommitFileUploadCallback>(Client, request.SourceJobID));
        }