Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.

Message Exchanges

tsimbalar edited this page Nov 21, 2012 · 7 revisions

This document is a list of the messages/notifications used for communication between the server and the client.

Communication Client -> Server

Id When Consequence
POST /rooms/:roomId/games/:gameId/solution Player wants to publish his solution Server should validate and take submission into account
  solution : {"moves":["{\"movement\":{\"robot\":\"Green\",\"originRow\":7,\"originColumn\":9,\"direction\":\"Down\"}}","{\"movement\":{\"robot\":\"Green\",\"originRow\":10,\"originColumn\":9,\"direction\":\"Right\"}}","{\"movement\":{\"robot\":\"Green\",\"originRow\":10,\"originColumn\":15,\"direction\":\"Down\"}}","{\"movement\":{\"robot\":\"Green\",\"originRow\":15,\"originColumn\":15,\"direction\":\"Left\"}}","{\"movement\":{\"robot\":\"Green\",\"originRow\":15,\"originColumn\":11,\"direction\":\"Up\"}}","{\"movement\":{\"robot\":\"Green\",\"originRow\":6,\"originColumn\":11,\"direction\":\"Left\"}}","{\"movement\":{\"robot\":\"Green\",\"originRow\":6,\"originColumn\":1,\"direction\":\"Down\"}}","{\"movement\":{\"robot\":\"Green\",\"originRow\":9,\"originColumn\":1,\"direction\":\"Left\"}}","{\"movement\":{\"robot\":\"Green\",\"originRow\":9,\"originColumn\":0,\"direction\":\"Down\"}}","{\"movement\":{\"robot\":\"Green\",\"originRow\":11,\"originColumn\":0,\"direction\":\"Up\"}}","{\"movement\":{\"robot\":\"Green\",\"originRow\":5,\"originColumn\":0,\"direction\":\"Right\"}}","{\"movement\":{\"robot\":\"Green\",\"originRow\":5,\"originColumn\":6,\"direction\":\"Up\"}}","{\"movement\":{\"robot\":\"Green\",\"originRow\":0,\"originColumn\":6,\"direction\":\"Left\"}}","{\"movement\":{\"robot\":\"Green\",\"originRow\":0,\"originColumn\":4,\"direction\":\"Down\"}}"]}
</td>
GET /rooms/:roomId/games/:gameId/status Check status of the game (how long is left, is the game over ...). Future : current phase of the game ? Allows to refresh game timer
  {"game":{"duration":180,"timeLeft":3,"status":"playing"}
GET /rooms/:roomId/games/:gameId/scores Get list of members + scores in the current game Allows to refresh list of players when somebody connects/disconnect and scores when somebody submits a solution

{"scores":[{"player":"hermione","score":0},{"player":"admin","score":0},{"player":"tibal","score":8}]}

POST /rooms/:roomId/eject Player wants to close existing sessions from another browser/computer ...

Communication Server-> Client

Id When Consequence
room.player.connected A player has just connected to the current room Client should refresh list of player
room.player.disconnected A player has just disconnected to the current room Client should refresh list of player
room.player.submittedSolution Somebody submitted a valid solution to the current game in the current room Client should refresh scores of current game
player.kickout Player has asked to close current existing session in another tab/browser in the same room Browser will stop the game in the ejected session/tab/browser

TODO - needed for future features

from server to client

  • change of game phase (for instance : somebody has submitted a solution ... now there is only 30 seconds left .... or time is up and user must show his solution to the world)
  • end of match (N games have been played ... show the overall winner)
  • end of game because all the other people have left the room
  • error notification ?? (server errors or things like that ??? )
  • movement notification in "replay mode" to show other player's solution (user is showing his solution)

from client to server

  • ask for the new board at the end of a game (no need to leave page)
  • submit solution "step by step" (to forward to other players, looking at the proposed solution) ....