Skip to content
Snippets Groups Projects
Commit 9cf576e0 authored by Victor Löfgren's avatar Victor Löfgren
Browse files

Update backend documentation

parent 95f583cf
No related branches found
No related tags found
1 merge request!159Resolve "Documentation"
...@@ -54,22 +54,28 @@ In this way, for example, an entire competition with it's teams, codes, slides a ...@@ -54,22 +54,28 @@ In this way, for example, an entire competition with it's teams, codes, slides a
## Active competitions ## Active competitions
Slides, timers and answers needs to be synced during an active presentation. Slides and timers (and answers) needs to be synced during an active presentation.
This is done using SocketIO together with flask_socketio. This is done using SocketIO together with flask_socketio.
Events sent is also authorized via json web tokens. Events sent is also authorized via JWT, basically the same way as the for the API calls.
But for socket events, the decorator that is used to authenticate them is `@authorize_user()`.
Whenever client joins a competition they will connect via sockets. Whenever client joins a competition they will connect via sockets.
Only a single instance of a competition can be active at a time. A single competition cannot be active more than once at the same time.
This means that you will need to make a copy of a competition if you want to run multiple times at the same time.
All of the functionality related to an active competition and sockets can be found in the file `app/core/sockets.py`. All of the functionality related to an active competition and sockets can be found in the file `app/core/sockets.py`.
The terms `active competition` and `presentation` means the same thing.
### Starting and joing presentations ### Starting and joing presentations
Whenever a client types in a code in the client, the code will be checked via the `api/auth/login/code` API call. Whenever a client types in a code in the client it will be checked via the `api/auth/login/code` API call.
If there is such a code and it was an operator code, the client will receive a JWT it will need to use to authenticate itself for there on out. If there is such a code and it was an operator code, the client will receive a JWT it will need to use to authenticate itself.
It will also emit the `start_presentation` event to start the presentation.
If there is such a code and the associated competition is active, the client will also receive a JWT, regardless if it was an operator code or not. If there is such a code and the associated competition is active, the client will also receive a JWT, regardless if it was an operator code or not.
In this case the client will instead emit the `join_presentation` event. Both of these cases will be handled by the default `connect` event, using the JWT received from the API call.
The server can see what is stored in the JWT and do different things depending on it's contents.
### Syncing between clients ### Syncing between clients
The operator will emit `set_slide` and `set_timer` events that syncs their slides and timers between all clients connected to the same presentation. The operator will emit the `sync` event and provide either slide or timer to update it on the server.
The operator can also emit `end_presentation` to end the current presentation, which will disconnect all connected clients. The server will then send `sync` to all connected clients with the updated values, regardless of what was actually updated.
The server will also store the timer and active slide in order to `sync` clients when they join.
The operator can also emit `end_presentation` to disconnect all clients from it's competitions.
This will also end the presentation.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment