Creates a new RoomController instance and initializes the socket connection.
the host used when creating the socket connection.
The ID of the room to connect to.
What cookies are currently set.
A function to allow updating cookies.
A function called when the connection was opened the first time.
Auto reconnect timeout. If set, then auto reconnect is currently running or failed.
The config of this room
The current ping in milliseconds.
The amount of filtered songs
ReadonlygetWhat cookies are currently set.
Readonlyhostthe host used when creating the socket connection.
OptionalpingThe interval of the ping function.
The current ping sequence number.
The performance.now() timestamp when the last ping was sent.
The list of songs played in the last round.
The name of the song artist.
A URL to the audio file of the song. Currently only audio previews from Apple Music, SoundCloud and YT are allowed.
Cover URL of the song.
The URL users will be redirected to when clicking.
The name of the song.
The current list of playlists selected for the game.
Cover URL of the playlist.
The URL users will be redirected to when clicking.
Name of the playlist
A list of song names and music urls
Optionalsubtitle?: stringAn optional subtitle with additional information about the playlist
The last received sequence number by the server.
The currently cached ingame data
Whether the WebSocket is currently reconnecting
ReadonlyroomThe ID of the room to connect to.
Private OptionalroomA map of all active (online, non-spectating) players. Key is server generated uuid, NOT connection id.
The current game state
The player's unique identifier generated by the server. Not connection id!
ReadonlysetA function to allow updating cookies.
ReadonlysetA function called when the connection was opened the first time.
PrivatesocketThe PartySocket instance used for server communication.
Whether we are just spectating.
PrivatestateListeners that are called whenever the state of the room changes.
Whether the current player is the host of the room.
The current list of non-spectating player messages of this room.
OptionalanswerData?: {The current answer of this player.
Optionalanswer?: stringProvided only for PlayerPicksGame. The answer the player selected.
OptionalanswerIndex?: numberProvided only for MultipleChoiceGame. The index of the question the player selected.
OptionalanswerSpeed?: numberThe relative time in ms a player took to answer a round question.
OptionalanswerTimestamp?: numberThe absolute time in ms where the player answered a round question.
The points the player got for the current question.
The player's color
OptionalhasPicked?: booleanTrue, if this player has picked a song in player picks. Ommitted otherwise.
True, if the receiver is the host
True, if this player is just spectating
How many points the player had in the last round.
The player's username
The server generated uuid, NOT the connection id.
The current list of players in the room.
The current list of spectating player messages of this room.
OptionalanswerData?: {The current answer of this player.
Optionalanswer?: stringProvided only for PlayerPicksGame. The answer the player selected.
OptionalanswerIndex?: numberProvided only for MultipleChoiceGame. The index of the question the player selected.
OptionalanswerSpeed?: numberThe relative time in ms a player took to answer a round question.
OptionalanswerTimestamp?: numberThe absolute time in ms where the player answered a round question.
The points the player got for the current question.
The player's color
OptionalhasPicked?: booleanTrue, if this player has picked a song in player picks. Ommitted otherwise.
True, if the receiver is the host
True, if this player is just spectating
How many points the player had in the last round.
The player's username
The server generated uuid, NOT the connection id.
The current game state.
The user's id.
The current username of the player.
The server-assigned uuid of this player.
Requests the server to add a playlist
the playlists to add
Cover URL of the playlist.
The URL users will be redirected to when clicking.
Name of the playlist
A list of song names and music urls
Optionalsubtitle?: stringAn optional subtitle with additional information about the playlist
PrivatecallCalls all registered state change listeners.
the received ServerMessage that caused the state change
The duration of the progressbar.
The number of seconds to offset the progress bar start point.
Whether to perform advanced filtering tactics when generating the songs array. Currently just ignores parens when filtering for identical song names.
Whether to allow changing answer in multiple choice.
The music start position for a game.
Must be a float between
and
Can be null to use random position (multiple choice) / let picker decide (player picks)
Whether to prefer distractions by the same artist.
Whether to directly end the round after all players answered.
The game mode being played.
The amount of multiple choice answers to add.
The amount of time a player should have to pick a song.
The amount of rounds to play.
The time per question in each round.
The added log message.
The log level of the added message.
The current game phase.
Optionalquestion?: The round number.
URL to load music from.
The current countdown number. 0 to hide.
The songs that were played in this round.
The count of filtered songs.
Optionalplaylists?: {Currently selected playlist(s)
A map of all active (online, non-spectating) players. Key is server generated uuid, NOT connection id.
The current game state
The player's unique identifier generated by the server. Not connection id!
Optionalerror?: stringOptional error message if the requested action could not be performed.
The message that is being confirmed.
The sequence number the pong should respond with
The sequence number asked for in the ping packet.
Whether the current question in player picks was selected by the provided uuid.
the uuid to check.
true if the game mode is player picks and the current round message pickerId matches the provided uuid.
Cleans up resources.
whether to also close the socket connection.
Serializes the current collection of playlists into a standardized JSON string.
PrivatehandleHandles the auto reconnect timeout waiting. Shows fatal error dialog if auto reconnect fails.
PrivatehandlePrivate
Handles a message sent from the server.
the message the server sent.
The duration of the progressbar.
The number of seconds to offset the progress bar start point.
Whether to perform advanced filtering tactics when generating the songs array. Currently just ignores parens when filtering for identical song names.
Whether to allow changing answer in multiple choice.
The music start position for a game.
Must be a float between
and
Can be null to use random position (multiple choice) / let picker decide (player picks)
Whether to prefer distractions by the same artist.
Whether to directly end the round after all players answered.
The game mode being played.
The amount of multiple choice answers to add.
The amount of time a player should have to pick a song.
The amount of rounds to play.
The time per question in each round.
The added log message.
The log level of the added message.
The current game phase.
Optionalquestion?: The round number.
URL to load music from.
The current countdown number. 0 to hide.
The songs that were played in this round.
The count of filtered songs.
Optionalplaylists?: {Currently selected playlist(s)
A map of all active (online, non-spectating) players. Key is server generated uuid, NOT connection id.
The current game state
The player's unique identifier generated by the server. Not connection id!
Optionalerror?: stringOptional error message if the requested action could not be performed.
The message that is being confirmed.
The sequence number the pong should respond with
The sequence number asked for in the ping packet.
Imports playlists from a validated PlaylistsFile object.
The validated PlaylistsFile object containing playlist data.
The playlists of this export.
Version of this export. Only used for validation.
PrivateonHandles the "close" event of the socket connection.
The CloseEvent containing details about the disconnection.
PrivateonHandles the "error" event of the socket connection.
The ErrorEvent containing details about the error.
PrivateonHandles incoming messages from the server.
The MessageEvent containing the server message.
PrivateonHandles the "open" event of the socket connection.
Sends the picked song to the server for PlayerPicksGame.
The song the player picked.
The name of the song artist.
A URL to the audio file of the song. Currently only audio previews from Apple Music, SoundCloud and YT are allowed.
Cover URL of the song.
The URL users will be redirected to when clicking.
The name of the song.
The start position for the audio.
Emits a countdown end event to be consumed by the audio player.
Emits a countdown running event to be consumed by the audio player.
(Re)connect to the PartyKit server with options.
if this is null, request a new username when reconnecting.
whether the player wants to spectate the game.
Registers a listener that will be called whenever the state of the room changes.
The ListenerCallback function.
A function to unregister the listener.
Requests the server to remove a playlist from the list.
the index of the playlist to remove. null to remove all playlists.
Requests the server to return to the lobby.
Sends the selected answer to the server for MultipleChoiceGame.
The index of the selected answer (0-3).
Sends the text answer (song guess) to the server for PlayerPicksGame.
The song name the player guessed.
Asks the server to update config.
PrivatesendSends a ping with the current sequence number to the server and tracks the start timestamp.
Requests the server to start the game.
PrivatestartPrivate
Starts the ping interval if not running. Will send pings to the server every second.
PrivatestopStops the auto reconnecting.
PrivatestopPrivate
Stops ping interval if running.
Requests a host transfer from the server.
The name of the player that should get host.
Unregisters a previously registered state change listener.
The ListenerCallback function.
Updates the username of the current player.
The new username to set.
Manages the connection and state of a room.