Specification of the data that needs to be sent to the WebSocket connection to execute a given function. For each function, you can find the data structure and an example of a working command.
[from METHOD /endpoint]
[from client]
wss://w1ws57hjh0.execute-api.eu-central-1.amazonaws.com/prod/
{"action":"check","type":"redis","method":"player","pid":"00001","gid":"18062024-2210"}
where pid is playerID and gid is gameID.${gameID}
. It also creates the first empty planet in the planets array (in the elasticache-tax-game cache with the key planets
).
{"action":"game","type":"createGame","gameID":"18062024-1845","stageTime":20,"auditChance":0.25,"finePercent":0.15,"planetCollectionMultiplier":1.7,"taxRate":0.30, "declaredIncomePercent": 0.40, "incomeMax":1200, "incomeMin":600, "bankruptcyThreshold": 0, "generateNewIncomeEachRound": false}
${gameID}---${playerID}
. It will return a generated role and planet to each connection (once the planet is established), and update the host with the new player (playerID and name).
DynamoDBStack-WebsocketConnections87C62C57-1H8H09K1YWXHY
table. If there is a record in the table with the same connectionId & gameID, it gets that object from Elasticache and returns the full item to the user.{"action":"game","type":"joinGame","gameID":"game-c3b4i7ybc","playerID":"001a","name":"Emma"}
Each time a player sends a joinGame request, the host will receive the following string: {"type":"startGame","message":[{"planetID":"planet1","planetName":"Terralus","players":[{"connectionID":"ZqGUhc8pliACFpw=","playerID":"00001","playerName":"Emma","role":"A"},{"connectionID":"ZqGWHc1-FiACETQ=","playerID":"00002","playerName":"Jules","role":"B"},{"connectionID":"ZqGXndKyFiACEXA=","playerID":"00003","playerName":"Stevie","role":"C"}]}]}
planetsObject[newestPlanet.players.indexOf(player)].players.push
{"type":"startGame","message":{{"planetID":"planet1","planetName":"Soralia","playerRole":"C","players":["Emma","Jules","Steve","Thomas","Kelvin","Dana"]}}
DynamoDBStack-WebsocketConnections87C62C57-1H8H09K1YWXHY
with the given gameID, and then sends each connection the response message.
stageChanges
is sent by a player that needed to make an action during that stage:
stageChanges
requeststageChanges
requeststageChanges
requeststageChanges
requesthandleStage
should be sent by the Host when the stage is up (stageDuration has elapsed). All players will be alerted that they must send their stageChanges
request
stageChanges
is sent in handleStage
.401 BAD REQUEST
if it’s missing{"type":"stageChanges","message":"OK"}
{"action":"game","type":"stageChanges","gameID":"18062024-2210","round":1,"stage":1,"playerID":"00001","planetID":"planet1","taxRate":0.7}
{"type":"handleStage","message":{"value":"TIME UP"}}
{"type":"startStage","message":{"round":1,"stage":2,"stageStartTime":"19/06/2024, 12:11:11","stageDuration":20,"taxRate":0.15}}
{"type":"startStage","message":{"round":1,"stage":3,"stageStartTime":"19/06/2024, 16:21:12","stageDuration":20,"bankrupt":false,"declared":[800,1100,600,600],"redistributable":3689}}
A Players | Bankrupt
{"type":"startStage","message":{"round":1,"stage":3,"stageStartTime":"19/06/2024, 16:21:12","stageDuration":20,"bankrupt":true}}
Other Players
{"type":"startStage","message":{"round":1,"stage":3,"stageStartTime":"19/06/2024, 16:21:12","stageDuration":20}}
{"type":"startStage","message":{"round":1,"stage":4,"stageStartTime":"20/06/2024, 12:04:48","stageDuration":20,"updatedWealth":3850,"auditPool":850}}
B+C Players
{"type":"startStage","message":{"round":1,"stage":4,"stageStartTime":"20/06/2024, 12:04:48","stageDuration":20,"updatedWealth":137.8,"rebate":137.8}}