Skip to content

Instantly share code, notes, and snippets.

@iodiot
Created September 28, 2016 06:22
Show Gist options
  • Save iodiot/45d6ab2a2f9ed3b7a13ff03a6949fbd6 to your computer and use it in GitHub Desktop.
Save iodiot/45d6ab2a2f9ed3b7a13ff03a6949fbd6 to your computer and use it in GitHub Desktop.
private bool LoadSnapshot()
{
try
{
var pendingResult = GamesClass.Snapshots.Open(client, SavedGameFileName, true);
var result = pendingResult.AsAsync<ISnapshotsOpenSnapshotResult>().Result;
var retriesCount = 2;
while (retriesCount-- > 0)
{
var code = result.Status.StatusCode;
if (code == STATUS_OK)
{
snapshot = result.Snapshot;
return true;
}
else if (code == STATUS_SNAPSHOT_CONTENTS_UNAVAILABLE)
{
snapshot = result.Snapshot;
return true;
}
else if (code == STATUS_SNAPSHOT_CONFLICT)
{
var conflictId = result.ConflictId;
var serverSnapshot = result.Snapshot;
var conflictedSnapshot = result.ConflictingSnapshot;
pendingResult = GamesClass.Snapshots.ResolveConflict(client, conflictId, conflictedSnapshot);
result = pendingResult.AsAsync<ISnapshotsOpenSnapshotResult>().Result;
}
}
}
catch(Exception e)
{
core.DebugMessage(e.Message);
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment