Example #1
0
        internal static void OnWriteFileComplete(IntPtr address)
        {
            OnWriteFileCompleteCallback callback     = null;
            WriteFileCallbackInfo       callbackInfo = null;

            if (Helper.TryGetAndRemoveCallback <OnWriteFileCompleteCallback, WriteFileCallbackInfoInternal, WriteFileCallbackInfo>(address, out callback, out callbackInfo))
            {
                callback(callbackInfo);
            }
        }
        /// <summary>
        /// Write new data to a specific file, potentially overwriting any existing file by the same name, to the cloud. This request will occur asynchronously, potentially over multiple frames.
        /// All callbacks for this function will come from the same thread that the SDK is ticked from. If specified, the FileTransferProgressCallback will always be called at least once if the
        /// request is started successfully.
        /// <seealso cref="PlayerDataStorageFileTransferRequest.Release" />
        /// </summary>
        /// <param name="writeOptions">Object containing properties related to which user is writing the file, what the file's name is, and related mechanisms for writing the data</param>
        /// <param name="clientData">Optional pointer to help clients track this request, that is returned in associated callbacks</param>
        /// <param name="completionCallback">This function is called when the write operation completes</param>
        /// <returns>
        /// A valid Player Data Storage File Request handle if successful, or NULL otherwise. Data contained in the completion callback will have more detailed information about issues with the request in failure cases. This handle must be released when it is no longer needed
        /// </returns>
        public PlayerDataStorageFileTransferRequest WriteFile(WriteFileOptions writeOptions, object clientData, OnWriteFileCompleteCallback completionCallback)
        {
            System.IntPtr writeOptionsAddress = new System.IntPtr();
            Helper.TryMarshalSet <WriteFileOptionsInternal, WriteFileOptions>(ref writeOptionsAddress, writeOptions);

            var clientDataAddress = System.IntPtr.Zero;

            var completionCallbackInternal = new OnWriteFileCompleteCallbackInternal(OnWriteFileCompleteCallbackInternalImplementation);

            Helper.AddCallback(ref clientDataAddress, clientData, completionCallback, completionCallbackInternal, writeOptions.WriteFileDataCallback, WriteFileOptionsInternal.WriteFileDataCallback, writeOptions.FileTransferProgressCallback, WriteFileOptionsInternal.FileTransferProgressCallback);

            var funcResult = EOS_PlayerDataStorage_WriteFile(InnerHandle, writeOptionsAddress, clientDataAddress, completionCallbackInternal);

            Helper.TryMarshalDispose(ref writeOptionsAddress);

            PlayerDataStorageFileTransferRequest funcResultReturn;

            Helper.TryMarshalGet(funcResult, out funcResultReturn);
            return(funcResultReturn);
        }
Example #3
0
        /// <summary>
        /// Write new data to a specific file, potentially overwriting any existing file by the same name, to the cloud. This request will occur asynchronously, potentially over multiple frames.
        /// All callbacks for this function will come from the same thread that the SDK is ticked from. If specified, the FileTransferProgressCallback will always be called at least once if the
        /// request is started successfully.
        /// <seealso cref="PlayerDataStorageFileTransferRequest.Release" />
        /// </summary>
        /// <param name="writeOptions">Object containing properties related to which user is writing the file, what the file's name is, and related mechanisms for writing the data</param>
        /// <param name="clientData">Optional pointer to help clients track this request, that is returned in associated callbacks</param>
        /// <param name="completionCallback">This function is called when the write operation completes</param>
        /// <returns>
        /// A valid Player Data Storage File Request handle if successful, or NULL otherwise. Data contained in the completion callback will have more detailed information about issues with the request in failure cases. This handle must be released when it is no longer needed
        /// </returns>
        public PlayerDataStorageFileTransferRequest WriteFile(WriteFileOptions writeOptions, object clientData, OnWriteFileCompleteCallback completionCallback)
        {
            var writeOptionsInternal = Helper.CopyProperties <WriteFileOptionsInternal>(writeOptions);

            var completionCallbackInternal = new OnWriteFileCompleteCallbackInternal(OnWriteFileComplete);
            var clientDataAddress          = IntPtr.Zero;

            Helper.AddCallback(ref clientDataAddress, clientData, completionCallback, completionCallbackInternal, writeOptions.WriteFileDataCallback, writeOptionsInternal.WriteFileDataCallback, writeOptions.FileTransferProgressCallback, writeOptionsInternal.FileTransferProgressCallback);

            var funcResult = EOS_PlayerDataStorage_WriteFile(InnerHandle, ref writeOptionsInternal, clientDataAddress, completionCallbackInternal);

            Helper.TryMarshalDispose(ref writeOptionsInternal);

            var funcResultReturn = Helper.GetDefault <PlayerDataStorageFileTransferRequest>();

            Helper.TryMarshalGet(funcResult, out funcResultReturn);
            return(funcResultReturn);
        }