Last active
August 29, 2015 14:21
-
-
Save Shogan/853ee54b3ec0a405ef0e to your computer and use it in GitHub Desktop.
FetchAllCharactersFromAWS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void FetchAllCharactersFromAWS() | |
{ | |
resultText.text = "\n***LoadTable***"; | |
Table.LoadTableAsync(_client, "CharacterCreator", (loadTableResult) => | |
{ | |
if (loadTableResult.Exception != null) | |
{ | |
resultText.text += "\n failed to load characters table"; | |
} | |
else | |
{ | |
try | |
{ | |
var context = Context; | |
// Note scan is pretty slow for large datasets compared to a query, as we are not searching on the index. | |
var search = context.ScanAsync<CharacterEntity>(new ScanCondition("Age", ScanOperator.GreaterThan, 0)); | |
search.GetRemainingAsync(result => | |
{ | |
if (result.Exception == null) | |
{ | |
characterEntities = result.Result; | |
// Load the first character into the character display | |
if (characterEntities.Count > 0) LoadCharacter(characterEntities.First()); | |
} | |
else | |
{ | |
Debug.LogError("Failed to get async table scan results: " + result.Exception.Message); | |
} | |
}, null); | |
} | |
catch (AmazonDynamoDBException exception) | |
{ | |
Debug.Log(string.Concat("Exception fetching characters from table: {0}", exception.Message)); | |
Debug.Log(string.Concat("Error code: {0}, error type: {1}", exception.ErrorCode, exception.ErrorType)); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment