玩游戏快照冲突解决会产生冲突 您所在的位置:网站首页 解决冲突的方式 玩游戏快照冲突解决会产生冲突

玩游戏快照冲突解决会产生冲突

2023-03-13 09:51| 来源: 网络整理| 查看: 265

Snapshots.OpenSnapshotResult result; result = Games.Snapshots.open(googleApiClient, "save", true).await(); while (result == null || !result.getStatus().isSuccess()) { Log.d("Snapshot", "Open snapshot"); if (result.getStatus().getStatusCode() == GamesStatusCodes.STATUS_SNAPSHOT_CONFLICT) { Snapshot snapshot = result.getSnapshot(); Snapshot cOnflictSnapshot= result.getConflictingSnapshot(); // Resolve between conflicts by selecting the newest of the conflicting snapshots. Snapshot mResolvedSnapshot = snapshot; if (snapshot.getMetadata().getLastModifiedTimestamp()

但是,此代码一直停留在while循环中.result保持状态STATUS_SNAPSHOT_CONFLICT.关于为什么没有得到解决的任何想法?

1> Clayton Wilk..:

根据两个版本之间发生的提交数量,您可能需要解决该循环中的多个冲突.它应该最终停止:)这可能需要很长时间.

有关详细信息,请参阅:https://developers.google.com/games/services/android/savedgames#handling_saved_game_conflicts

// Some large number to be defensive against an infinite loop. static final int MAX_SNAPSHOT_RESOLVE_RETRIES = 100; Snapshots.OpenSnapshotResult result; result = Games.Snapshots.open(googleApiClient, "save", true).await(); Snapshot snapshot = processSnapshotOpenResult(result, int retryCount); Snapshot processSnapshotOpenResult(Snapshots.OpenSnapshotResult result, int retryCount) { Snapshot mResolvedSnapshot = null; retryCount++; int status = result.getStatus().getStatusCode(); Log.i(TAG, "Save Result status: " + status); if (status == GamesStatusCodes.STATUS_OK) { return result.getSnapshot(); } else if (status == GamesStatusCodes.STATUS_SNAPSHOT_CONTENTS_UNAVAILABLE) { return result.getSnapshot(); } else if (status == GamesStatusCodes.STATUS_SNAPSHOT_CONFLICT) { Snapshot snapshot = result.getSnapshot(); Snapshot cOnflictSnapshot= result.getConflictingSnapshot(); // Resolve between conflicts by selecting the newest of the conflicting snapshots. mResolvedSnapshot = snapshot; if (snapshot.getMetadata().getLastModifiedTimestamp()


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有