Agon
A minimal, PoC game server for the Virtual Infrastructure subject's project using microservices.
The implementation uses Node.js and socket.io. Amazon S3 will be used for persistent storage.
Represents an instance of an Agon game server. Handles incoming requests (e.g. new players, match requests, etc.) and dispatches them to the corresponding classes.
The constructor expects a Socket.io instance, which will handle the actual communication with the clients.
Represents a room with players where a game is taking place. It has a reference to a Game
instance and a list of the participating players. It's also the responsible of interfacing the server and the game.
The constructor expects a BaseGame
subclass, a Socket.io instance and a list of players.
Abstract class representing a certain match. Subclasses must implement the following method:
setupGame()
: called in the constructor, it should initialize the game statevalidateMove(player, move) : boolean
: decides whether a move made by a certain player is valid, and thus should be taking into account, or notmakeMove(player, move)
: updates the game state with the new moveisFinished() : boolean
: decides whether the game has already finished or notgetWinner() : int|null
: returns the winner of the game ornull
if there isn't one (e.g. draw)
Just npm test
.
Several classes are tested (unit testing):
TicTacToe
andNim
, the game engines for the games supportedRoom
andGameRoom
Server
The deployment URL is https://agon-server.herokuapp.com. The container URL is https://agon-server.herokuapp.com too. The Docker image can be found here. Final deployment: 13.81.248.48
Heroku is the chosen PaaS for the deploy because it's an established platform, it has plenty of resources and documentation for developers, and it has a decent free tier. In the future it might be moved to zeit.co or OpenShift.
As for the IaaS alternative, Azure was a good fit since we had free credits available. In order to deploy the application you can
vagrant up
npx shipit production deploy --shipitfile deployment/shipitfile.js
For more information, check the documentation.
To check that everything has gone smoothly, you can check the /status/
endpoint (or any other path, in fact) which should return a JSON payload containing "status": "OK"
.