Open Trivia uses socket.io for fast, real-time communication. The documentation below will provide a list of event names and arguments used.
Contestant Namespace - Used by all participants
Host Namespace - Used only by the event hosts
Contestants connect to the global namespace (/).
In order for a contestant to connect, they must first authenticate using their Team PIN. In addition, unless the OT_SKIP_NAMES environment variable is set to 1, they'll be required to go through the /identity path and enter their name.
Note that hosts also have access to the global namespace.
Each of these events are strings that can be sent from a client to the server, along with the corresponding arguments needed.
Returns the current state and status of a user's connection.
Argument: mode boolean
trueto recieve thestatusevent reply
Possible replies:
statusobject - if mode is set to falsevalidbooleanuserstring
config-bkstring - background image URLquestionobject - current question, if a question is active- object from
getCurrentQuestion()
- object from
announcementobject - current announcement, if an announcement is active- object from
currentMessage
- object from
scores-releaseno argument - if currently on the special "score release" page
Sent every ~6 seconds to ping the server.
Argument: none
Reply: pong no argument
Deprecated.
Used to join the hosts room. No longer used.
Used to submit an answer to a question.
Triggers the teamBroadcast function to ensure all teammates have the same information.
Argument: answer string
Reply:
- Non-timed questions:
answer-ackobject - answer acknowledgement, sent to the entire teamokboolean - if the answer was successfully submitted or notmsgstring - error details if ok was falsesenderboolean - whether the user recieving the acknowledgement was the user who originally submitted the answer[selected]string - what was selected (for teammates' devices), not always used
- Timed questions:
answer-timecorrectboolean - whether the answer submitted was correct[answer]string - the correct answer (if applicable)[time]number - time taken to answer, in ms[message]string - help message, if applicable (i.e., "too low" on a number)
Event sent when a user leaves their competition tab
Event sent when a user returns to their competition tab
Hosts connect to a host-specific, secure namespace (/secure).
In order for a host to connect, they must have authenticated via the host key set using the HOST_KEY environment variable. Otherwise, the connection request will be rejected.
Host documentation will be added in the coming few weeks.