Client Events
Your client should listen to these events.
Connected
Automatically sent when a user connects using socket.connect().
socket.on('connected', data => {
// Do stuff to set up the game, like hiding host only buttons
if(sessionStorage.getItem('uid') == uid) {
if(!document.getElementsByClassName('hostOnly')) return
for(const el of document.getElementsByClassName('hostOnly')){
el.style.display = 'inline-block'
}
}
sessionStorage.setItem('uid', data.user.uid)
})Parameters
data
Object
Object with game and user info. See structure below.
{
gameType: 'wyr/nhie/etc',
gameId: 'ID',
user: {
name:'Display Name',
picture: 'https://example.com/pfp.png',
uid:'UID',
host: true || false
},
host: 'HOST UID'
}Player Join
Parameters
data
Object
Object with player information.
Player Leave
Parameters
uid
String
The UID of the disconnecting player.
Votes
Get the votes sent from get_votes
Parameters
votes
Array
The votes, which are object containing the user's name & their answer.
New Question
Get the new data from next
Parameters
question
String or object
The modes with one question will return the card content as a string. The ones with more than one will return an object, where opt1 is the first option and opt2 is the second.
Error
Listen for errors.
Receive a Chat Message
Receive a chat message on the client.
Parameters
data
Object
An object containing the message (content) and author. See the structure below.
Players
Get an array of players from get_players
Parameters
data
Array
See structure below.
Kicking a User
Additional Word Wreck Events
Since Word Wreck has more components to it, it has a few extra events.
Vote
This will emit when everyone has submitted an answer to vote on.
Do not confuse this with votes for the other modes. Word Wreck involves 2 components to a round, with the 2nd being voting. This is for this 2nd round, not to get votes.
Parameters
voteOptions
Array
The answers to vote for. See structure below.
Winner
When everyone has voted, this event will emit with the winner.
Parameters
winner
Object
The name of the winner and their answer. See structure below.
New Host
If a new host is assigned, reflect that in your app.
Last updated
Was this helpful?