Websocket documentation

Karaoke Mugen's app sends websocket messages to client browsers to notify them of updates on the interface, or that they should query once again some API via HTTP to get updated.

Each message has a type (e.g. playerStatus) and data, either in JSOn or text.

Player events

playerStatus

JSON message indicating the current status of the app.

Properties

Example

{
    private: true,
    status: 'play',
    onTop: true,
    fullscreen: false,
    timePosition: 12.628,
    duration: 92,
    muteStatus: false,
    playerStatus: 'play',
    currentlyPlaying: 232,
    subText: 'DATABASE DATABASE WOW WOW',
    showSubs: true,
    volume: 100,
};

Poll events

songPollResult

Event sent when a song poll is finished so you can display who won and with how many votes

Properties

JSON object :

Example

{ 
    votes: 5,
    kara: 'Mahoromatic - AMV - Dernière Danse 2010'
}

songPollEnded

This message is sent if the poll system has been disabled. It has no data.

newSongPoll

This message is sent when a new poll has been started. It contains JSON data similar to a playlist contents from the API call GET /public/playlists/current/karas for example, or from the GET /public/songpoll call.

Playlists events

playlistsUpdated

Event sent when the list of playlists has been updated (creation/deletion/name change). It contains no data, and should trigger a refresh of the playlists list.s

playlistInfoUpdated

Event sent when a playlist information has been updated. Data is the playlist ID number. When received, it should trigger a refresh of that playlist status/list of playlists

playlistContentsUpdated

Event sent when a playlist has been modified. Data is the playlist ID number. When received, it should trigger a refresh of the playlist contents, if it is being displayed on screen.

blacklistUpdated

Event sent when the blacklist has been updated by an admin. You should refresh the main karas list as some songs might now be hidden/visible to the user. The blacklist contents should also be refreshed.

whitelistUpdated

See above.

User events

usersUpdated

Event sent when the list of users has been updated (new user...) It contains no data.

userUpdated

A specific user has been updated. Data is the user ID number.

adminMessage

Contains a message sent by the admin, to be displayed on the user's screen. Data is the message in question.

favoritesUpdated

A user's favorites has been updated. Data is the user's login name.

quotaAvailableUpdated

The number of songs/seconds a user has left has been updated. Data contains JSON with the properties according to the below example. Check out the configuration to learn more about user quotas.

Example

{ username: 'Axel', quotaLeft: 5, quotaType: 1 }