Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
© 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Dhruv Thukral, Amazon Web Services Solutions Arc...
Before We Start
How Do You Build a Mobile
Game Today?
Authenticate users
Manage users and identity providers
Authorize access
Securely access cloud resources
Synchronize data
S...
Send real time events
Create live dashboards to track user events in real time
Analyze user behavior
Track active users, e...
Introducing AWS Mobile Services
Amazon Cognito Amazon Mobile Analytics Amazon SNS Mobile Push
Amazon Kinesis
Recorder
Amaz...
Authenticate users
Manage users and identity providers
Authorize access
Securely access cloud resources
Synchronize data
S...
Send real time events
Create Live Dashboards to track user events in real time
Analyze user behavior
Track active users, e...
Authenticate users: Amazon Cognito
Amazon Cognito
Simplifies identity and
access management
Securely access all
AWS services from
mobile device
Cross-device ...
Amazon Cognito concepts
Identity pool
IAM roles, trust, and permissions
Identities: authenticated and unauthenticated
Getting started
Create an identity pool
Use SDK to get credentials
Create roles: authenticated and unauthenticated
Getting credentials
Include the following import statements
Initialize the Amazon Cognito credentials provider
Pass the in...
End Users
App with
AWS Mobile
SDK
Access
to AWS
Services
Login OAUTH/OpenID
Access Token
Amazon
Cognito ID,
Temp
Credentia...
Amazon Cognito ID
(Temp Credentials)
End Users
Access
to AWS
Services
Get OpenID Token
User name,
password
Amazon
Cognito ...
Synchronize data across devices : Amazon Cognito (Sync)
Amazon Cognito Sync
User data,
storage,
and sync
Any platform
iOS, Android, FireOS
Store app data, preferences, and state
...
Integrating Amazon Cognito Sync functionality is simple
Import the Amazon Cognito package
Initialize the Sync client and u...
Datasets
Create a dataset or open an existing one
To delete a dataset
Reading and writing to a dataset
Removing keys from ...
Store and deliver media assets:
Amazon S3 and Amazon CloudFront
Amazon S3 Connector: Transfer Utility
S3 Connector
• Multipart upload (e.g., user content)
• Fault tolerant download (e.g....
Integrating the S3 Transfer Utility is simple too!
Instantiate an Amazon S3 client
Instantiate TransferUtility
Performing operations
Upload an object
Download an object
Performing operations
Upload an object
Download an object
Tracking S3 transfer progress
Other operations
Pausing an S3 transfer
Resuming and S3 transfer
Cancelling an S3 transfer
Analyze user behavior: Amazon Mobile Analytics
Amazon Mobile Analytics
Scalable and generous
Free tier
Focus on metrics that matter; usage
reports available within 60 mi...
Integrating Mobile Analytics is guess what….simple!
Initialize the MobileAnalyticsManager and that’s it….
We saw earlier w...
Key business metrics
(with one line of code)
1. Monthly Active Users
(MAU)
2. Daily Active Users
(DAU)
3. New Users
4. Dai...
Get behavioral insights into app specific
actions that your users take
Reports provide a view of how often custom
events o...
Custom event tracking using Mobile Analytics
Create an AnalyticsEvent, pass attributes and metrics
Then record the event
Send push notifications: Amazon SNS mobile push
Each platform works differently, and push gets more complex as
you scale to support millions of devices
Cloud app
Platform...
Amazon SNS
Cross-platform
Mobile Push
Internet
Apple APNS
Google GCM
Amazon ADM
Windows WNS and
MPNS
Baidu CP
New features...
Store shared data: Amazon DynamoDB
Joe Anna Bob
Highscores
Joe 1500
Anna 800
Bob 750
Simplifies access to Amazon
DynamoDB in your app
Map client-side classes...
@DynamoDBTable(tableName = ”Highscores")
public static class HighScore{
private int userid, highScore;
private String name...
// Build a highscore object
HighScore highScore = new HighScore();
highScore.setUserId(17);
highScore.setName(”Joe");
high...
Quiz?
Q. What is the maximum number of datasets per identity in Amazon Cognito?
A. 20
Q. What object is returned by the Tr...
Tappy Plane Architecture
and Demo
Now over to Tara!!
Tappy Plane architecture
Mobile Client
AWS Unity
SDK
AWS Toolkit for
Visual Studio
Amazon Cognito
Identity
AWS Cloud
Dynam...
AWS Mobile SDKs for gaming
1. AWS Mobile SDK for Android
2. AWS Mobile SDK for iOS
3. AWS Mobile SDK for Unity (developer ...
Introducing the AWS SDK for Unity
Generally available, May 2015
Services available
 Amazon DynamoDB
 Amazon S3
 Amazon ...
SDK installation and setup
Download AWS Unity SDK and unzip
 http://aws.amazon.com/mobile/sdk/
Import the desired package...
Tappy Plane game
Game showcases
 Amazon Cognito Identity
 Amazon Cognito Sync
 Mobile Analytics
 Amazon S3 Transfer Ut...
Tappy Plane
AWS Mobile SDK: services setup
Tappy Plane : services setup
Set up Amazon Cognito identity pool
 Create Tappy Plane identity pool
 Retrieve identity po...
Tappy Plane demo
Setting up AWS services in the console
Tappy Plane demo
Amazon Cognito: reviewing Unity3D code
Adding DynamoDB
Methods to create DynamoDB table
 Using DynamoDB console
 Using code with createTable method
 Using Vis...
Using DynamoDB
Add a high score record
 Create high score object
[DynamoDBTable(”TappyHighScores")]
class HighScore
{ [Dy...
Adding Amazon Simple Storage Service (S3)
Methods create S3 bucket (set permissions)
 Using Amazon S3 console
 Using cod...
Using Amazon Simple Storage Service (S3)
Download an object
 Get badge picture (bragging rights)
var request = new GetObj...
AWS resources
AWS mobile blog
• http://mobile.awsblog.com
AWS Mobile Services
• http://aws.amazon.com/mobile/
AWS Mobile S...
Thank you!
Serverless Mobile App and Game Development
Build your game with Mobile Services
Tara Walker AWS Technical Evang...
Remember to complete
your evaluations!
Related Sessions
Nächste SlideShare
Wird geladen in …5
×

(GAM401) Build a Serverless Mobile Game w/ Cognito, Lambda & DynamoDB

9.622 Aufrufe

Veröffentlicht am

Get a hands-on walkthrough of how to quickly build a mobile game with online services like user authentication, downloadable content, and social features. Using the AWS Mobile SDK for Unity, iOS, and Android, it's easier than ever to build a game with these services. This session provides a step-by-step approach to add features to your game such as user identity management, dynamic content updates, cross-platform data sync, and more. We demonstrate how to use the AWS Mobile SDK to securely interact with services such as Amazon Cognito, Amazon DynamoDB, Amazon S3, and AWS Lambda.

Veröffentlicht in: Technologie
  • Login to see the comments

(GAM401) Build a Serverless Mobile Game w/ Cognito, Lambda & DynamoDB

  1. 1. © 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Dhruv Thukral, Amazon Web Services Solutions Architect, Gaming Tara E. Walker, AWS Technical Evangelist, Amazon Web Services October 2015 GAM 401 Serverless Mobile App and Game Development Build Your Game with Mobile Services
  2. 2. Before We Start
  3. 3. How Do You Build a Mobile Game Today?
  4. 4. Authenticate users Manage users and identity providers Authorize access Securely access cloud resources Synchronize data Sync user preferences across devices Store and deliver media Store DLC and deliver content quickly
  5. 5. Send real time events Create live dashboards to track user events in real time Analyze user behavior Track active users, engagement and stats Store shared data Store and query fast NoSQL data across users and devices Send push notifications Bring users back to your app by sending messages reliably
  6. 6. Introducing AWS Mobile Services Amazon Cognito Amazon Mobile Analytics Amazon SNS Mobile Push Amazon Kinesis Recorder Amazon DynamoDB Mapper Amazon S3 Transfer Util Amazon SQS Client Amazon SES Client Core building block services Mobile optimized connectors Mobile optimized services Your Mobile Game AWS Mobile SDK for iOS, Android, Xamarin and Unity, API Endpoints, Management Console Compute Storage Networking Analytics Databases Integrated SDK AWS Lambda Lambda Functions λ λ λ λ
  7. 7. Authenticate users Manage users and identity providers Authorize access Securely access cloud resources Synchronize data Sync user preferences across devices Store and deliver media Store DLC and deliver content quickly Amazon Cognito Sync Amazon Cognito Amazon Cognito S3 Transfer Utility
  8. 8. Send real time events Create Live Dashboards to track user events in real time Analyze user behavior Track active users, engagement and stats Store shared data Store and query fast NoSQL data across users and devices Send push notifications Bring users back to your app by sending messages reliably Kinesis Recorder DynamoDB Mapper Amazon SNS Mobile Push Amazon Mobile Analytics
  9. 9. Authenticate users: Amazon Cognito
  10. 10. Amazon Cognito Simplifies identity and access management Securely access all AWS services from mobile device Cross-device and cross-platform sync Implement security best practices “Your app data is secure, available offline, and kept in sync between devices” Synchronize user’s data across devices and platforms Manage users as unique identities across identity providers Guest Your own Auth
  11. 11. Amazon Cognito concepts Identity pool IAM roles, trust, and permissions Identities: authenticated and unauthenticated
  12. 12. Getting started Create an identity pool Use SDK to get credentials Create roles: authenticated and unauthenticated
  13. 13. Getting credentials Include the following import statements Initialize the Amazon Cognito credentials provider Pass the initialized Amazon Cognito credentials provider to the constructor of the AWS client to be used. This could be the Amazon Cognito Sync client, the Amazon S3 transfer manager, or any of the other mobile services we will talk about shortly.
  14. 14. End Users App with AWS Mobile SDK Access to AWS Services Login OAUTH/OpenID Access Token Amazon Cognito ID, Temp Credentials Access Token Pool ID Role ARNs Amazon Cognito ID (Temp Credentials) DynamoDB Developer Amazon Cognito Identity Broker S3 Mobile Analytics Amazon Cognito Sync Store AWS Management Console Amazon Cognito security architecture
  15. 15. Amazon Cognito ID (Temp Credentials) End Users Access to AWS Services Get OpenID Token User name, password Amazon Cognito ID, Temp Credentials OIDC Token Pool ID Role ARNs User Authentication System (Running on AWS or not) OIDC Token OIDC Token Developer authenticated identities S3 Mobile Analytics Amazon Cognito Identity Broker AWS Management Console Developer DynamoDB Amazon Cognito Sync Store
  16. 16. Synchronize data across devices : Amazon Cognito (Sync)
  17. 17. Amazon Cognito Sync User data, storage, and sync Any platform iOS, Android, FireOS Store app data, preferences, and state Save app and device data to the cloud and merge them after login Cross-device cross-OS sync Sync user data and preferences across devices with one line of code Work offline Data always stored in local SQLite DB first; works seamlessly when intermittent or no connectivity k/v data Identity pool
  18. 18. Integrating Amazon Cognito Sync functionality is simple Import the Amazon Cognito package Initialize the Sync client and use the previously created credentials provider
  19. 19. Datasets Create a dataset or open an existing one To delete a dataset Reading and writing to a dataset Removing keys from a dataset
  20. 20. Store and deliver media assets: Amazon S3 and Amazon CloudFront
  21. 21. Amazon S3 Connector: Transfer Utility S3 Connector • Multipart upload (e.g., user content) • Fault tolerant download (e.g., assets) • No back end required • Automatic retries • Pause, resume, cancel functions
  22. 22. Integrating the S3 Transfer Utility is simple too! Instantiate an Amazon S3 client Instantiate TransferUtility
  23. 23. Performing operations Upload an object Download an object
  24. 24. Performing operations Upload an object Download an object
  25. 25. Tracking S3 transfer progress
  26. 26. Other operations Pausing an S3 transfer Resuming and S3 transfer Cancelling an S3 transfer
  27. 27. Analyze user behavior: Amazon Mobile Analytics
  28. 28. Amazon Mobile Analytics Scalable and generous Free tier Focus on metrics that matter; usage reports available within 60 minutes of receiving data from an app Fast Scale to billions of events per day from millions of users Own your data “Easily collect, visualize and understand your app usage data at scale” Data collected are not shared, aggregated, or reused
  29. 29. Integrating Mobile Analytics is guess what….simple! Initialize the MobileAnalyticsManager and that’s it…. We saw earlier where we can find our identity pool ID. You can get the appid by creating a new app in the Mobile Analytics dashboard
  30. 30. Key business metrics (with one line of code) 1. Monthly Active Users (MAU) 2. Daily Active Users (DAU) 3. New Users 4. Daily Sessions 5. Sticky Factor 6. 1-day retention 7. Avg. revenue per DAU 8. Daily paying users 9. Avg. paying DAU Amazon Mobile Analytics dashboard
  31. 31. Get behavioral insights into app specific actions that your users take Reports provide a view of how often custom events occur; you can add further context with attributes and metrics, to each custom event Track the number of likes and shares, per article, in a news app Understand player abort rates per level, in a game Number of songs played, per user session, in a music app In-app item popularity in a shopping app Track custom events
  32. 32. Custom event tracking using Mobile Analytics Create an AnalyticsEvent, pass attributes and metrics Then record the event
  33. 33. Send push notifications: Amazon SNS mobile push
  34. 34. Each platform works differently, and push gets more complex as you scale to support millions of devices Cloud app Platform services Mobile apps
  35. 35. Amazon SNS Cross-platform Mobile Push Internet Apple APNS Google GCM Amazon ADM Windows WNS and MPNS Baidu CP New features: Message expiry time Message attributes Delivery status Broadcast iOS 9 support Amazon SNS mobile push Android Phones and Tablets Apple iPhones and iPads Kindle Fire Devices Android Phones and Tablets in China iOS Windows Desktop and Windows Phone Devices
  36. 36. Store shared data: Amazon DynamoDB
  37. 37. Joe Anna Bob Highscores Joe 1500 Anna 800 Bob 750 Simplifies access to Amazon DynamoDB in your app Map client-side classes to Amazon DynamoDB tables Removes the need to transform objects into tables and vice versa Amazon DynamoDB Connector: Object Mapper
  38. 38. @DynamoDBTable(tableName = ”Highscores") public static class HighScore{ private int userid, highScore; private String name; @DynamoDBHashKey(attributeName = ”userid") public int getUserId() { return userid; } public void setUserId(int userid) { this.userid = userid; } @DynamoDBAttribute(attributeName=”name") public String getName() { return name; }…… User ID Name High score 17 Joe 25 23 Anna 67 32 Bob 55 Table: high scores Amazon DynamoDB mapper example
  39. 39. // Build a highscore object HighScore highScore = new HighScore(); highScore.setUserId(17); highScore.setName(”Joe"); highScore.setHighScore(25); // Save book object to DynamoDB mapper.save(highScore); // Update item and save object again highScore.setHighScore(118); mapper.save(highScore); // Load another highScore HighScore anotherHighScore = mapper.load(HighScore.class,23); Amazon DynamoDB mapper example
  40. 40. Quiz? Q. What is the maximum number of datasets per identity in Amazon Cognito? A. 20 Q. What object is returned by the TransferUtility when calling an upload or download? A. TransferObserver Q. How many events can you store in the free tier for Mobile Analytics? Q. 100 MM
  41. 41. Tappy Plane Architecture and Demo Now over to Tara!!
  42. 42. Tappy Plane architecture Mobile Client AWS Unity SDK AWS Toolkit for Visual Studio Amazon Cognito Identity AWS Cloud DynamoDB Mobile Analytics Amazno Cognito Sync Login
  43. 43. AWS Mobile SDKs for gaming 1. AWS Mobile SDK for Android 2. AWS Mobile SDK for iOS 3. AWS Mobile SDK for Unity (developer preview)
  44. 44. Introducing the AWS SDK for Unity Generally available, May 2015 Services available  Amazon DynamoDB  Amazon S3  Amazon Cognito  Amazon Mobile Analytics  Amazon SNS Other AWS services Invoke Lambda with SNS and/or S3 events Build custom plugins for other AWS services using AWS Mobile SDK for.NET
  45. 45. SDK installation and setup Download AWS Unity SDK and unzip  http://aws.amazon.com/mobile/sdk/ Import the desired package(s) into Unity as a custom package  CognitoSync package  DynamoDB package  S3 package  MobileAnalytics package Add the AWSPrefab to scene in Unity
  46. 46. Tappy Plane game Game showcases  Amazon Cognito Identity  Amazon Cognito Sync  Mobile Analytics  Amazon S3 Transfer Utility  DynamoDB Mapper Want More Game Samples?  AWS Unity SDK samples available on GitHub https://github.com/awslabs/aws-sdk-unity-samples
  47. 47. Tappy Plane AWS Mobile SDK: services setup
  48. 48. Tappy Plane : services setup Set up Amazon Cognito identity pool  Create Tappy Plane identity pool  Retrieve identity pool ID Set up Mobile Analytics app  Add Tappy Plane app  Retrieve app ID Create Tappy Plane high score table  Create table  Add hash key  Add table attributes
  49. 49. Tappy Plane demo Setting up AWS services in the console
  50. 50. Tappy Plane demo Amazon Cognito: reviewing Unity3D code
  51. 51. Adding DynamoDB Methods to create DynamoDB table  Using DynamoDB console  Using code with createTable method  Using Visual Studio with AWS Toolkit for Visual Studio: http://aws.amazon.com/net/  Example: • Table name: TappyHighScores • Primary key type: Hash • Hash attribute name: ScoreID, • Hash type: Number Create DynamoDB client AmazonDynamoDBClient client = new AmazonDynamoDBClient(RegionEndpoint.USEast1)
  52. 52. Using DynamoDB Add a high score record  Create high score object [DynamoDBTable(”TappyHighScores")] class HighScore { [DynamoDBHashKey] // hash key public int ScoreID { get; set; } [DynamoDBProperty] public string Score { get; set; } public string UserID {get; set; } }  Save high score record to DynamoDB _context.SaveAsync<HighScore>(myScore, (AmazonDynamoResult<VoidResponse> result) => { if (result.Exception != null) { this.displayMessage += "Save failed ; “ +result.Exception.Message; } High scores Joe 1500 Anna 800 Bob 750
  53. 53. Adding Amazon Simple Storage Service (S3) Methods create S3 bucket (set permissions)  Using Amazon S3 console  Using code with PutBucket and PutBucketRequest  Using Visual Studio with AWS Toolkit for Visual Studio: http://aws.amazon.com/net/  Example: Bucket name: tappyplane_bucket Create an Amazon S3 transfer manager AmazonS3Client S3Client = new AmazonS3Client (credentials ,RegionEndpoint.USEast1);
  54. 54. Using Amazon Simple Storage Service (S3) Download an object  Get badge picture (bragging rights) var request = new GetObjectRequest () { BucketName = bucketName, Key = downloadKey, }; S3Client.GetObjectAsync (request, GetObjectCallback,null); Upload an object  Upload a picture of high score Stream stream = null; stream = new FileStream(uploadSrcFilePath, FileMode.Open, FileAccess.Read, FileShare.Read); var postRequest = new PostObjectRequest { Key = uploadKey, Bucket = bucketName, InputStream = stream }; S3Client.PostObjectAsync (postRequest, PostObjectCallback,null);
  55. 55. AWS resources AWS mobile blog • http://mobile.awsblog.com AWS Mobile Services • http://aws.amazon.com/mobile/ AWS Mobile SDK • http://aws.amazon.com/mobile/sdk/ AWS mobile developer guides • Unity: http://docs.aws.amazon.com/mobile/sdkforunity/developerguide • iOS: http://docs.aws.amazon.com/mobile/sdkforios/developerguide • Android: http://docs.aws.amazon.com/mobile/sdkforandroid/developerguide/We lcome.html
  56. 56. Thank you! Serverless Mobile App and Game Development Build your game with Mobile Services Tara Walker AWS Technical Evangelist, Amazon Web Services Dhruv Thukral Amazon Web Services Solutions Architect, Gaming
  57. 57. Remember to complete your evaluations!
  58. 58. Related Sessions

×