Definitions
Client (Host): client who creates the lobby and is on the beeg screen
Client (Player): client who joins the lobby and plays the game
Starting a game
Client (Host) sends:
{
"command": "host",
"id": "<kahoot id>"
}
If successful, server returns:
{
"success": true,
"gameId": "<some game id>",
"gameName": "<kahoot game name>",
"questionCount": 69
}
Default error response for everything:
{
"success": false,
"message": "<error message go brrrr>"
}
Client (Host) displays game code which is used by Clients (Players) to join with the message:
{
"command": "join",
"gameId": "<some game id>",
"playerName": "<some player name>"
}
Server returns this unless an error was encountered.
Every time a player joins, the server sends to Client (Host) the following
{
"event": "newPlayer",
"playerName": "<player name>"
}
Client (Host) presses start game button and sends:
During the game
Initially the host is sent the first question and the clients are broadcast the message
{
"event": "questionStart",
"numberOfAnswers": 4
}
Every question is sent to the host in the following format:
{
"question": "<question text>",
"duration": 20,
"answers": [
{
"text": "<answer text>",
"correct": true
}
]
}
When the time is up, the host sends:
{
"command": "leaderboard"
}
The server returns
{
"leaderboard": [
{
"userName": "<some user name>",
"points": 69420,
"streak": 3
}
]
}
When the host is ready for the next question, they send
{
"command": "question"
}
When a player guesses an answer, they send
{
"command": "guess",
"index": 0
}
When the round ends and the leaderboard is shown, the server sends each player
{
"event": "questionEnd",
"correct": true,
"pointsThisRound": 800,
"pointsTotal": 69420,
"streak": 2,
"position": 3,
"behind": "<player name or null>"
}
At the end of the game, every player is sent
{
"event": "end",
"position": 3
}