A websocket server to enable simple multi-player functionality.
Supported functionality:
-
Create a Room
-
Join a Room
-
Leave a Room
-
List Room
-
Start Game
-
Reset Game
-
End Game
-
Next Game Question
The backend server perform admin and user functions using websockets.
-
Initiate the quizzrr websocket server
./q-server
-
Open a new terminal to accept
websocketcommands. -
To interact with the application use the
websocattool to send message to the api.Example: To run the
websocatserver onlocalhostwebsocat ws://localhost:8080/ws
NOTE: Use
nixto run websocatnix-shell -p websocat
With the websocket available, send the required command to the backend api. Available commands are detailed below:
- Role: Admin
- Description: Create a game room defined by the room_id.
| Role | JSON |
|---|---|
| Admin | {"type": "create_room", "room_id": "room123"} |
- Admins can create a room on the server
{"type": "create_room", "room_id": "room123"} - Admins can create a room on the server
{"type": "create_room", "room_id": "room113"} - Admins can create a room on the server
{"type": "create_room", "room_id": "room103"}
Players can join the room by using the room_id
Users can join a game room defined by entering the room_id.
| Role | JSON |
|---|---|
| User | {"type": "join_room", "room_id": "room123", "name": "Alice"} |
-
Add user:
Alice{"type":"join_room","room_id":"room123","client_id":"cli-alice","role":"player","name":"Alice"} -
Add user:
Bob{"type":"join_room","room_id":"room123","client_id":"cli-bob","role":"player","name":"Bob"} -
Add user:
Carol{"type":"join_room","room_id":"room123","client_id":"cli-carol","role":"player","name":"Carol"} -
Add user:
Danny{"type":"join_room","room_id":"room123","client_id":"cli-danny","role":"player","name":"Danny"}
Admin can start a game room defined by the room_id.
| Role | JSON |
|---|---|
| Admin | {"type": "start_room", "room_id": "room123"} |
- Admin start a game in
room_id{"type": "start_room", "room_id": "room123"}
Admin can reset a game defined by the room_id.
| Role | JSON |
|---|---|
| Admin | {"type": "reset_game", "room_id": "room123"} |
- End the game defined by
room_id{"type": "reset_game", "room_id": "room123"}
Admin can end a game defined by the room_id.
| Role | JSON |
|---|---|
| Admin | {"type": "end_game", "room_id": "room123"} |
- End the game defined by
room_id{"type": "end_room", "room_id": "room123"}
Users can list room and metadata.
| Role | JSON |
|---|---|
| Users | {"type": "list_rooms"} |
- List rooms
{"type": "list_rooms"}
Admin can indicate to move to the next question.
| Role | JSON |
|---|---|
| Admin | {"type": "next_question", "room_id": "room123"} |
- Admin event to move to the next question
{"type": "next_question", "room_id": "room123"}
