Skip to content

Socket Architecture

Leon Chin edited this page Apr 13, 2021 · 3 revisions

All Listeners will have corresponding emitters on frontend/backend either as a function itself or nested in other functions

Frontend Listeners

'countdown'

  • This listener is used to move all the players from the lobby screen to the countdown screen to begin the game.

'end_game'

  • This listener is used to notify the users that the game has ended and disconnects them from the socket connection and sends them to the results page

'invalid_code'

  • This Listener is used to notify the user whether the code they entered is valid or not, or if the room is full

'new_user'

  • This Listener is used to sync the people in the lobby with all the clients. users join and leave in realtime.

'next_round'

  • This Listener is used so the server can sync the rounds for all players and tell them when a round ends and when the next should begin.

'update_restaurants'

  • This listener is used to send the preferences and restaurant data to all clients. This helps reduce the number of API calls to the Restaurants API

Backend Listeners

'disconnect'

  • when a user disconnects from a socket, they must also disconnect from any game lobby they are in

'join_room'

  • When a user joins a room the server must check if the room code is valid and also not full, then all other users are notified of a new joiner and the new joiner is sent the list of restaurants

'leave_room'

  • When a user manually leaves the room, it should do similar things to disconnect^

'set_restaurants'

  • When a host decides on preferences and the list of restaurants are loaded, it is saved in the server

'start'

  • When a host press starts, this starts the game cycle in the backend

'vote'

  • When players vote the votes are sent though this socket and recorded in the backend

'host_room'

  • When a host creates a room, should be called to associate the host socket with the room

Clone this wiki locally