public void CommitAndClose(AN_SnapshotsClient client, AN_Snapshot snapshot, AN_SnapshotMetadataChange metadataChange, Action <AN_SnapshotMetadataResult> callback) { SA_Coroutine.WaitForSeconds(1, () => { var result = new AN_SnapshotMetadataResult(new AN_SnapshotMetadata()); callback.Invoke(result); }); }
private void ReadAndWrite(string name) { var client = AN_Games.GetSnapshotsClient(); client.Open(name, m_createIfNotFound, m_conflictPolicy, (result) => { if (result.IsSucceeded) { AN_Logger.Log("We have snapshot, reading data..."); AN_Snapshot snapshot = result.Data.GetSnapshot(); byte[] data = snapshot.ReadFully(); var meta = snapshot.GetMetadata(); m_progress = meta.ProgressValue + 10; m_playedTime = meta.PlayedTime + 100; string base64Text = Convert.ToBase64String(data); AN_Logger.Log("Snapshot data: " + base64Text); PrintSnapshotMetadata(snapshot.GetMetadata()); AN_Logger.Log("Writing data..."); m_snpashotData = "My game data " + name; data = m_snpashotData.ToBytes(); snapshot.WriteBytes(data); SA_ScreenUtil.TakeScreenshot(512, (screenshot) => { var changeBuilder = new AN_SnapshotMetadataChange.Builder(); changeBuilder.SetDescription("Hello Description"); changeBuilder.SetPlayedTimeMillis(m_playedTime); changeBuilder.SetProgressValue(m_progress); changeBuilder.SetCoverImage(screenshot); AN_SnapshotMetadataChange changes = changeBuilder.Build(); client.CommitAndClose(snapshot, changes, (commitResult) => { if (commitResult.IsSucceeded) { PrintSnapshotMetadata(commitResult.Metadata); VerifySnapshotsSave(name); } else { SetAPIResult(result); } }); }); } else { SetAPIResult(result); } }); }
private void OpenSnapshot(string name) { var client = AN_Games.GetSnapshotsClient(); bool createIfNotFound = true; var conflictPolicy = AN_SnapshotsClient.ResolutionPolicy.LAST_KNOWN_GOOD; client.Open(name, createIfNotFound, conflictPolicy, (result) => { if (result.IsSucceeded) { Debug.Log("We have snapshot, reading data..."); AN_Snapshot snapshot = result.Data; byte[] data = snapshot.ReadFully(); long progress = snapshot.GetMetadata().ProgressValue; string base64Text = Convert.ToBase64String(data); Debug.Log("Snapshot data: " + base64Text); Debug.Log("Snapshot progress: " + snapshot.GetMetadata().ProgressValue); Debug.Log("Snapshot played time: " + snapshot.GetMetadata().PlayedTime); Debug.Log("Writing data..."); string mydata = "My game data"; data = mydata.ToBytes(); snapshot.WriteBytes(data); SA_ScreenUtil.TakeScreenshot(512, (screenshot) => { var changeBuilder = new AN_SnapshotMetadataChange.Builder(); changeBuilder.SetDescription("Hello Description"); changeBuilder.SetPlayedTimeMillis(10000); changeBuilder.SetProgressValue(progress + 1); changeBuilder.SetCoverImage(screenshot); AN_SnapshotMetadataChange changes = changeBuilder.Build(); client.CommitAndClose(snapshot, changes, (commitResult) => { if (commitResult.IsSucceeded) { PrintMeta(commitResult.Metadata); } else { Debug.Log("CommitAndClose Snapshots Failed: " + result.Error.FullMessage); } }); }); } else { Debug.Log("Open Snapshots Failed: " + result.Error.FullMessage); } }); }
private void SaveAndroidSnapShotGame(string name, byte[] data, AN_SnapshotMetadataChange meta, Action <SA_Result> callback) { var client = AN_Games.GetSnapshotsClient(); //This resolution is picked since this is the only we can currently implement for iOS //so we pick same one for android, just to be consistent. var conflictPolicy = AN_SnapshotsClient.ResolutionPolicy.MOST_RECENTLY_MODIFIED; client.Open(name, true, conflictPolicy, (result) => { if (result.IsSucceeded) { var snapshot = result.Data.GetSnapshot(); snapshot.WriteBytes(data); client.CommitAndClose(snapshot, meta, commitResult => { ReportGameSave(name, result); callback.Invoke(result); }); } else { callback.Invoke(result); } }); }
public void CommitAndClose(AN_SnapshotsClient client, AN_Snapshot snapshot, AN_SnapshotMetadataChange metadataChange, Action <AN_SnapshotMetadataResult> callback) { AN_Java.Bridge.CallStaticWithCallback(AN_SnapshotsClient, "CommitAndClose", callback, client.HashCode, snapshot.HashCode, metadataChange); }