diff --git a/docs/source/overview/server.md b/docs/source/overview/server.md index 314ff853f3643d15098158c2c80ec1783babe315..5711a0b57f8604b0a954e8854fa9f513c9ebc60e 100644 --- a/docs/source/overview/server.md +++ b/docs/source/overview/server.md @@ -54,22 +54,28 @@ In this way, for example, an entire competition with it's teams, codes, slides a ## 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. -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. -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`. +The terms `active competition` and `presentation` means the same thing. ### 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. -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. -It will also emit the `start_presentation` event to start the presentation. +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. 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 -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 can also emit `end_presentation` to end the current presentation, which will disconnect all connected clients. +The operator will emit the `sync` event and provide either slide or timer to update it on the server. +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.