CharacterCreator-startup-and-initialisation
// Setup our credentials which will use our Cognito identity pool to hand us short-term session credentials, | |
// giving us access to what we have provided access to with our IAM role policies, in this case, access to our | |
// DynamoDB table. | |
credentials = new CognitoAWSCredentials(cognitoIdentityPoolString, RegionEndpoint.USEast1); | |
credentials.GetIdentityIdAsync(delegate(AmazonCognitoIdentityResult<string> result) | |
{ | |
if (result.Exception != null) | |
{ | |
Debug.LogError("exception hit: " + result.Exception.Message); | |
} | |
// Create a DynamoDB client, passing in our credentials from Cognito. | |
var ddbClient = new AmazonDynamoDBClient(credentials, RegionEndpoint.USEast1); | |
resultText.text += ("\n*** Retrieving table information ***\n"); | |
// Create a DescribeTableRequest to get information about our table, and ensure we can access it. | |
var request = new DescribeTableRequest | |
{ | |
TableName = @"CharacterCreator" | |
}; | |
ddbClient.DescribeTableAsync(request, (ddbresult) => | |
{ | |
if (result.Exception != null) | |
{ | |
resultText.text += result.Exception.Message; | |
Debug.Log(result.Exception); | |
return; | |
} | |
var response = ddbresult.Response; | |
// Debug information | |
TableDescription description = response.Table; | |
resultText.text += ("Name: " + description.TableName + "\n"); | |
resultText.text += ("# of items: " + description.ItemCount + "\n"); | |
resultText.text += ("Provision Throughput (reads/sec): " + description.ProvisionedThroughput.ReadCapacityUnits + "\n"); | |
resultText.text += ("Provision Throughput (reads/sec): " + description.ProvisionedThroughput.WriteCapacityUnits + "\n"); | |
}, null); | |
// Set our _client field to the dynamoDB client. | |
_client = ddbClient; | |
// Fetch any stored characters from the DB | |
FetchAllCharactersFromAWS(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment