Skip to content

Latest commit

 

History

History
174 lines (117 loc) · 3.45 KB

File metadata and controls

174 lines (117 loc) · 3.45 KB

Quizzrr Server

A websocket server to enable simple multi-player functionality.

Backend API

Supported functionality:

  • Create a Room

  • Join a Room

  • Leave a Room

  • List Room

  • Start Game

  • Reset Game

  • End Game

  • Next Game Question

Architecture

The backend server perform admin and user functions using websockets.

q-server

Running the q-server

  1. Initiate the quizzrr websocket server

    ./q-server
  2. Open a new terminal to accept websocket commands.

  3. To interact with the application use the websocat tool to send message to the api.

    Example: To run the websocat server on localhost

    websocat ws://localhost:8080/ws

    NOTE: Use nix to run websocat

    nix-shell -p websocat

With the websocket available, send the required command to the backend api. Available commands are detailed below:

Create Room

  • Role: Admin
  • Description: Create a game room defined by the room_id.
Role JSON
Admin {"type": "create_room", "room_id": "room123"}
  1. Admins can create a room on the server
    {"type": "create_room", "room_id": "room123"}
  2. Admins can create a room on the server
    {"type": "create_room", "room_id": "room113"}
    
  3. Admins can create a room on the server
    {"type": "create_room", "room_id": "room103"}

Players can join the room by using the room_id

Join Room

Users can join a game room defined by entering the room_id.

Role JSON
User {"type": "join_room", "room_id": "room123", "name": "Alice"}
  1. Add user: Alice

    {"type":"join_room","room_id":"room123","client_id":"cli-alice","role":"player","name":"Alice"}
  2. Add user: Bob

    {"type":"join_room","room_id":"room123","client_id":"cli-bob","role":"player","name":"Bob"}
  3. Add user: Carol

    {"type":"join_room","room_id":"room123","client_id":"cli-carol","role":"player","name":"Carol"}
  4. Add user: Danny

    {"type":"join_room","room_id":"room123","client_id":"cli-danny","role":"player","name":"Danny"}

Start Game

Admin can start a game room defined by the room_id.

Role JSON
Admin {"type": "start_room", "room_id": "room123"}
  1. Admin start a game in room_id
    {"type": "start_room", "room_id": "room123"}

Reset Game

Admin can reset a game defined by the room_id.

Role JSON
Admin {"type": "reset_game", "room_id": "room123"}
  1. End the game defined by room_id
    {"type": "reset_game", "room_id": "room123"}

End Game

Admin can end a game defined by the room_id.

Role JSON
Admin {"type": "end_game", "room_id": "room123"}
  1. End the game defined by room_id
    {"type": "end_room", "room_id": "room123"}

List Room

Users can list room and metadata.

Role JSON
Users {"type": "list_rooms"}
  1. List rooms
    {"type": "list_rooms"}

Next Question

Admin can indicate to move to the next question.

Role JSON
Admin {"type": "next_question", "room_id": "room123"}
  1. Admin event to move to the next question
    {"type": "next_question", "room_id": "room123"}