Skip to content

mzaradzki/serverless_othello_game

Repository files navigation

serverless_othello_game

Serverless Othello board game using AWS

We want to implement an HTML+JS version of thr Othello board game where user actions are process through AWS Lambda :

  • AWS Lambda will receive user action and update the state of the game - DONE
  • AWS DynamoDB will store the state of the game - DONE
  • AWS DynamoDB will store the list of players - DONE
  • AWS Cognito Dataset to store Facebook friends - DONE
  • AWS Cognito will handle user authentification - DONE
  • AWS CognitoSyncManager to synchronize across devices - DONE (to store Facebook friend list)
  • AWS S3 will store the website files - OPTIONAL TO DO (can store on Git Pages !)
  • AWS CloudFormation configuration template - OPTIONAL TO DO

IMPROVEMENTS TO DO a) The game already works however the many calls to the DB make the interface slow when opening/refreshing a page. This would be more transparent to the user if we relied on Cognito Dataset for all the data (only FB friends at present) so that on any device at any time most of the data is in sync. The DB call would only update the local copies of the Datasets to synchronize them regularly. b) When moving from the index to the game page it seems the FB login page slows the transition, maybe there is a way to keep the FB login info across pages ?

NOTE To notify users when it's their turn to play the plan was to use AWS SNS push notification, however this is only available for Android and iOS devices, so for the moment the game will rely on regular pull calls insteads of pushes.

AWS IAM Roles

  • Cognito_{SOME_NAME}Auth_Role : generated by Cognito, can invoke Lambda, can query DB by key (no scan)
  • Cognito_{SOME_NAME}Unauth_Role : generated by Cognito, has no right
  • {SOME_NAME}_lambda_role : a custom role assumed by the Lambda functions, has DB access

AWS DynamoDB tables

  • OthelloGames : primary key = game_id, secondary keys = black_player_identity_id and white_player_identity_id
  • OthelloPlayers : primary key = facebook_id

AWS Lambda functions

  • playerStore : store facebook_id and cognito_id in OthelloPlayers table
  • gameCreate : create a new record in OthelloGames table
  • gameReset : update a record in OthelloGames table
  • gameUpdate : update a record in OthelloGames table

Inspirations taken from these tutorials :

To save all the AWS configurations one can use a template file such as ChessGameCloudFormationTemplate.template in this project :

NOTE To use Cognito Sync Manager in the browser we need to host a copy of this package : https://github.com/aws/amazon-cognito-js

NOTE When testing it is best to emulate a server rather than directly opening the html files in the browser. For example launch the site from the console with : python -m SimpleHTTPServer

Misc.

  • When creating a game needs to pass identityId to Lambda function to record the 2 game owners - DONE
  • When loading a game needs to pass identityId to Lambda to check against game owners
  • When logging-off needs to delete credentials and to reset UI - DONE (via url redirect) BUT CAN DO CLEANER
  • A user should not be able to create a new fresh game (unknown game partner) if he already has one in the DB
  • A user should not be able to have more than 1 game open against a given game partner
  • Display a listing of open/closed games for a given user - DONE
  • When the opponent move a piece, would be nice to get a clear signal (image or sound) that it is our turn to play
  • When the opponent move a piece, would be nice to see the piece that was moved with an highlight
  • Would be nice to see timers of the time taken by each player... unless they play in several sessions
  • There is a small UI bug when a user plays his turn but his move is sent to the db during a game state pull query