public override void GetDatasetMetadataAsync(string datasetName, AmazonCognitoCallback callback, object state)
        {
            DescribeDatasetRequest request = new DescribeDatasetRequest();

            //appendUserAgent(request, userAgent);
            request.IdentityPoolId = identityPoolId;
            request.IdentityId     = this.GetCurrentIdentityId();
            request.DatasetName    = datasetName;
            client.DescribeDatasetAsync(request, delegate(AmazonServiceResult describeDatasetResult)
            {
                AmazonCognitoResult callbackResult = new AmazonCognitoResult(state);
                if (describeDatasetResult.Exception != null)
                {
                    callbackResult.Exception = new DataStorageException("Failed to get metadata of dataset: "
                                                                        + datasetName, describeDatasetResult.Exception);
                }
                else
                {
                    callbackResult.Response = new DatasetMetadataResponse
                    {
                        Metadata = ModelToDatasetMetadata((describeDatasetResult.Response as DescribeDatasetResponse).Dataset)
                    };
                }
                AmazonMainThreadDispatcher.ExecCallback(callback, callbackResult);
            }, null);
        }
Ejemplo n.º 2
0
 private void RefreshDatasetMetadataCallback(AmazonCognitoResult result)
 {
     if (result.Exception == null)
     {
         characters.Synchronize();
         Debug.Log("RefreshDatasetMetadataAsync complete");
     }
     else
     {
         Debug.LogException(result.Exception);
     }
 }
 private void RefreshDatasetMetadataCallback(AmazonCognitoResult result)
 {
     if (result.Exception == null)
     {
         Debug.Log("RefreshDatasetMetadataAsync complete");
         statusMessage = "Refreshing metadata complete";
         playerInfo.Synchronize();
         playerSettings.Synchronize();
     }
     else
     {
         Debug.Log("RefreshDatasetMetadataAsync failed");
         statusMessage = "Refreshing metadata failed";
         Debug.LogException(result.Exception);
         disableButton = false;
     }
 }
        public override void PutRecordsAsync(string datasetName, List <Record> records, string syncSessionToken, AmazonCognitoCallback callback, object state)
        {
            UpdateRecordsRequest request = new UpdateRecordsRequest();

            //appendUserAgent(request, userAgent);
            request.DatasetName      = datasetName;
            request.IdentityPoolId   = identityPoolId;
            request.IdentityId       = this.GetCurrentIdentityId();
            request.SyncSessionToken = syncSessionToken;

            // create patches
            List <RecordPatch> patches = new List <RecordPatch>();

            foreach (Record record in records)
            {
                patches.Add(this.RecordToPatch(record));
            }
            request.RecordPatches = patches;

            List <Record> updatedRecords = new List <Record>();

            client.UpdateRecordsAsync(request, delegate(AmazonServiceResult result)
            {
                AmazonCognitoResult callbackResult = new AmazonCognitoResult(state);

                if (result.Exception != null)
                {
                    callbackResult.Exception = HandleException(result.Exception, "Failed to update records in dataset: " + datasetName);
                }
                else
                {
                    UpdateRecordsResponse updateRecordsResponse = result.Response as UpdateRecordsResponse;
                    foreach (Amazon.CognitoSync.Model.Record remoteRecord in updateRecordsResponse.Records)
                    {
                        updatedRecords.Add(ModelToRecord(remoteRecord));
                    }
                    callbackResult.Response = new PutRecordsResponse {
                        UpdatedRecords = updatedRecords
                    };
                }

                AmazonMainThreadDispatcher.ExecCallback(callback, callbackResult);
            }, null);
        }
        public override void DeleteDatasetAsync(string datasetName, AmazonCognitoCallback callback, object state)
        {
            DeleteDatasetRequest request = new DeleteDatasetRequest();

            //appendUserAgent(request, userAgent);
            request.IdentityPoolId = identityPoolId;
            request.IdentityId     = this.GetCurrentIdentityId();
            request.DatasetName    = datasetName;
            client.DeleteDatasetAsync(request, delegate(AmazonServiceResult deleteDatasetResult)
            {
                AmazonCognitoResult result = new AmazonCognitoResult(state);
                if (deleteDatasetResult.Exception == null)
                {
                    result.Exception = HandleException(deleteDatasetResult.Exception, "Failed to delete dataset: " + datasetName);
                }
                else
                {
                    result.Exception = new Exception("Unsupported DeleteDatasetAsync");
                    //result.Response = deleteDatasetResult.Response;
                }
                AmazonMainThreadDispatcher.ExecCallback(callback, result);
            }, null);
        }
 internal static void ExecCallback(AmazonCognitoCallback callback, AmazonCognitoResult result)
 {
     _callbackQueue.Enqueue(new AmazonCognitoCallbackState(callback, result));
 }
 public AmazonCognitoCallbackState(AmazonCognitoCallback callback, AmazonCognitoResult result)
 {
     this._callback = callback;
     this._result   = result;
 }