The WebSocket part of CAH Creator. Allows for live updates and collaboration.
Everything here works based on sessions. Here's how it works:
- User connects
- User either sends auth token or session ID/token pair.
- If auth token:
- Session server contacts cahcreator.com to verify auth token
- If session ID/token:
- Session server verifies locally if session with ID exists and that it has the matching token.
- Once authenticated:
- If auth token:
- Session server contacts cahcreator.com again, this time verifying if the user has access to the deck.
- If
has_access
is true (or user is admin), create a session and send the deck information to the user.
- If session ID/token:
- Send deck information over to user (authentication is implied).
- Add them to session.
- On disconnect:
- If user is session creator:
- Send
session:end
message to all users in session. - Nullify session.
- Clean up.
- Send
- If user is not session creator:
- Remove user from session.
- Do nothing.