SongGuess
    Preparing search index...

    Manages the connection and state of a room.

    Index
    • Creates a new RoomController instance and initializes the socket connection.

      Parameters

      • host: string

        the host used when creating the socket connection.

      • roomID: string

        The ID of the room to connect to.

      • getCookies: CookieGetter

        What cookies are currently set.

      • setCookies: CookieSetter

        A function to allow updating cookies.

      • setIsReady: (ready: boolean) => void

        A function called when the connection was opened the first time.

      Returns RoomController

    autoReconnectTimeout: number | null = null

    Auto reconnect timeout. If set, then auto reconnect is currently running or failed.

    config: BaseConfig = ...

    The config of this room

    currentPingMs: number = -1

    The current ping in milliseconds.

    filteredSongsCount: number = 0

    The amount of filtered songs

    getCookies: CookieGetter

    What cookies are currently set.

    host: string

    the host used when creating the socket connection.

    pingInterval?: number

    The interval of the ping function.

    pingSeq: number = 0

    The current ping sequence number.

    pingStart: number = 0

    The performance.now() timestamp when the last ping was sent.

    playedSongs: {
        artist: string;
        audioURL: string;
        cover: string | null;
        hrefURL: string;
        name: string;
    }[] = []

    The list of songs played in the last round.

    Type Declaration

    • artist: string

      The name of the song artist.

    • audioURL: string

      A URL to the audio file of the song. Currently only audio previews from Apple Music, SoundCloud and YT are allowed.

    • cover: string | null

      Cover URL of the song.

    • hrefURL: string

      The URL users will be redirected to when clicking.

    • name: string

      The name of the song.

    playlists: {
        cover: string | null;
        hrefURL: string;
        name: string;
        songs: {
            artist: string;
            audioURL: string;
            cover: string | null;
            hrefURL: string;
            name: string;
        }[];
        subtitle?: string;
    }[] = []

    The current list of playlists selected for the game.

    Type Declaration

    • cover: string | null

      Cover URL of the playlist.

    • hrefURL: string

      The URL users will be redirected to when clicking.

    • name: string

      Name of the playlist

    • songs: {
          artist: string;
          audioURL: string;
          cover: string | null;
          hrefURL: string;
          name: string;
      }[]

      A list of song names and music urls

    • Optionalsubtitle?: string

      An optional subtitle with additional information about the playlist

    pongSeq: number = 0

    The last received sequence number by the server.

    questionData: QuestionData = ...

    The currently cached ingame data

    reconnecting: boolean = false

    Whether the WebSocket is currently reconnecting

    roomID: string

    The ID of the room to connect to.

    roomState?: {
        players: Record<
            string,
            {
                answerData?: {
                    answer?: string;
                    answerIndex?: number;
                    answerSpeed?: number;
                    answerTimestamp?: number;
                    questionPoints: number;
                };
                color: string;
                hasPicked?: boolean;
                isHost: boolean;
                isSpectator: boolean;
                points: number;
                username: string;
                uuid: string;
            },
        >;
        state: "lobby"
        | "results"
        | "ingame";
        type: "room_state";
        uuid: string;
    }

    Type Declaration

    • players: Record<
          string,
          {
              answerData?: {
                  answer?: string;
                  answerIndex?: number;
                  answerSpeed?: number;
                  answerTimestamp?: number;
                  questionPoints: number;
              };
              color: string;
              hasPicked?: boolean;
              isHost: boolean;
              isSpectator: boolean;
              points: number;
              username: string;
              uuid: string;
          },
      >

      A map of all active (online, non-spectating) players. Key is server generated uuid, NOT connection id.

    • state: "lobby" | "results" | "ingame"

      The current game state

    • type: "room_state"
    • uuid: string

      The player's unique identifier generated by the server. Not connection id!

    setCookies: CookieSetter

    A function to allow updating cookies.

    setIsReady: (ready: boolean) => void

    A function called when the connection was opened the first time.

    socket: PartySocket

    The PartySocket instance used for server communication.

    spectator: boolean = true

    Whether we are just spectating.

    stateChangeEventListeners: ListenerCallback[] = []

    Listeners that are called whenever the state of the room changes.

    • get playerMessages(): {
          answerData?: {
              answer?: string;
              answerIndex?: number;
              answerSpeed?: number;
              answerTimestamp?: number;
              questionPoints: number;
          };
          color: string;
          hasPicked?: boolean;
          isHost: boolean;
          isSpectator: boolean;
          points: number;
          username: string;
          uuid: string;
      }[]

      The current list of non-spectating player messages of this room.

      Returns {
          answerData?: {
              answer?: string;
              answerIndex?: number;
              answerSpeed?: number;
              answerTimestamp?: number;
              questionPoints: number;
          };
          color: string;
          hasPicked?: boolean;
          isHost: boolean;
          isSpectator: boolean;
          points: number;
          username: string;
          uuid: string;
      }[]

      • OptionalanswerData?: {
            answer?: string;
            answerIndex?: number;
            answerSpeed?: number;
            answerTimestamp?: number;
            questionPoints: number;
        }

        The current answer of this player.

        • Optionalanswer?: string

          Provided only for PlayerPicksGame. The answer the player selected.

        • OptionalanswerIndex?: number

          Provided only for MultipleChoiceGame. The index of the question the player selected.

        • OptionalanswerSpeed?: number

          The relative time in ms a player took to answer a round question.

        • OptionalanswerTimestamp?: number

          The absolute time in ms where the player answered a round question.

        • questionPoints: number

          The points the player got for the current question.

      • color: string

        The player's color

      • OptionalhasPicked?: boolean

        True, if this player has picked a song in player picks. Ommitted otherwise.

      • isHost: boolean

        True, if the receiver is the host

      • isSpectator: boolean

        True, if this player is just spectating

      • points: number

        How many points the player had in the last round.

      • username: string

        The player's username

      • uuid: string

        The server generated uuid, NOT the connection id.

    • get players(): Map<
          string,
          {
              answerData?: {
                  answer?: string;
                  answerIndex?: number;
                  answerSpeed?: number;
                  answerTimestamp?: number;
                  questionPoints: number;
              };
              color: string;
              hasPicked?: boolean;
              isHost: boolean;
              isSpectator: boolean;
              points: number;
              username: string;
              uuid: string;
          },
      >

      The current list of players in the room.

      Returns Map<
          string,
          {
              answerData?: {
                  answer?: string;
                  answerIndex?: number;
                  answerSpeed?: number;
                  answerTimestamp?: number;
                  questionPoints: number;
              };
              color: string;
              hasPicked?: boolean;
              isHost: boolean;
              isSpectator: boolean;
              points: number;
              username: string;
              uuid: string;
          },
      >

    • get spectatorPlayerMessages(): {
          answerData?: {
              answer?: string;
              answerIndex?: number;
              answerSpeed?: number;
              answerTimestamp?: number;
              questionPoints: number;
          };
          color: string;
          hasPicked?: boolean;
          isHost: boolean;
          isSpectator: boolean;
          points: number;
          username: string;
          uuid: string;
      }[]

      The current list of spectating player messages of this room.

      Returns {
          answerData?: {
              answer?: string;
              answerIndex?: number;
              answerSpeed?: number;
              answerTimestamp?: number;
              questionPoints: number;
          };
          color: string;
          hasPicked?: boolean;
          isHost: boolean;
          isSpectator: boolean;
          points: number;
          username: string;
          uuid: string;
      }[]

      • OptionalanswerData?: {
            answer?: string;
            answerIndex?: number;
            answerSpeed?: number;
            answerTimestamp?: number;
            questionPoints: number;
        }

        The current answer of this player.

        • Optionalanswer?: string

          Provided only for PlayerPicksGame. The answer the player selected.

        • OptionalanswerIndex?: number

          Provided only for MultipleChoiceGame. The index of the question the player selected.

        • OptionalanswerSpeed?: number

          The relative time in ms a player took to answer a round question.

        • OptionalanswerTimestamp?: number

          The absolute time in ms where the player answered a round question.

        • questionPoints: number

          The points the player got for the current question.

      • color: string

        The player's color

      • OptionalhasPicked?: boolean

        True, if this player has picked a song in player picks. Ommitted otherwise.

      • isHost: boolean

        True, if the receiver is the host

      • isSpectator: boolean

        True, if this player is just spectating

      • points: number

        How many points the player had in the last round.

      • username: string

        The player's username

      • uuid: string

        The server generated uuid, NOT the connection id.

    • Requests the server to add a playlist

      Parameters

      • ...playlists: {
            cover: string | null;
            hrefURL: string;
            name: string;
            songs: {
                artist: string;
                audioURL: string;
                cover: string | null;
                hrefURL: string;
                name: string;
            }[];
            subtitle?: string;
        }[]

        the playlists to add

        • cover: string | null

          Cover URL of the playlist.

        • hrefURL: string

          The URL users will be redirected to when clicking.

        • name: string

          Name of the playlist

        • songs: {
              artist: string;
              audioURL: string;
              cover: string | null;
              hrefURL: string;
              name: string;
          }[]

          A list of song names and music urls

        • Optionalsubtitle?: string

          An optional subtitle with additional information about the playlist

      Returns void

    • Calls all registered state change listeners.

      Parameters

      • msg:
            | { duration: number; offset: number; type: "progressbar_update" }
            | {
                advancedSongFiltering: boolean;
                allowChangingAnswer: boolean;
                audioStartPosition: number | null;
                distractionsPreferSameArtist: boolean;
                endWhenAnswered: boolean;
                gameMode: "multiple_choice" | "player_picks";
                multipleChoiceAnswersCount: number;
                playerPickTimeout: number;
                roundsCount: number;
                timePerQuestion: number;
                type: "room_config";
            }
            | {
                entry: LogEntry;
                level: "error"
                | "info"
                | "warn"
                | "debug";
                type: "add_log_message";
            }
            | { messages: LoggerStorage; type: "update_log_messages" }
            | {
                gamePhase: GamePhase;
                question?:
                    | {
                        answerOptions: string[];
                        correctAnswerIndex?: number;
                        questionType: "multiple_choice";
                        startPos: number;
                    }
                    | {
                        correctAnswer?: {
                            artist: string;
                            audioURL: string;
                            cover: string
                            | null;
                            hrefURL: string;
                            name: string;
                        };
                        pickerId: string;
                        questionCount: number;
                        questionCurrent: number;
                        questionType: "player_picks";
                        startPos: number;
                    };
                roundCurrent: number;
                type: "round_state";
            }
            | { action: "load"; audioURL: string; type: "audio_control" }
            | {
                action:
                    | "play"
                    | "pause"
                    | "play_countdown_running"
                    | "play_countdown_end";
                type: "audio_control";
            }
            | { countdown: number; type: "countdown" }
            | {
                songs: {
                    artist: string;
                    audioURL: string;
                    cover: string | null;
                    hrefURL: string;
                    name: string;
                }[];
                type: "update_played_songs";
            }
            | {
                filteredSongsCount: number;
                playlists?: {
                    cover: string
                    | null;
                    hrefURL: string;
                    name: string;
                    songs: {
                        artist: string;
                        audioURL: string;
                        cover: string | null;
                        hrefURL: string;
                        name: string;
                    }[];
                    subtitle?: string;
                }[];
                type: "update_playlists";
            }
            | {
                players: Record<
                    string,
                    {
                        answerData?: {
                            answer?: string;
                            answerIndex?: number;
                            answerSpeed?: number;
                            answerTimestamp?: number;
                            questionPoints: number;
                        };
                        color: string;
                        hasPicked?: boolean;
                        isHost: boolean;
                        isSpectator: boolean;
                        points: number;
                        username: string;
                        uuid: string;
                    },
                >;
                state: "lobby"
                | "results"
                | "ingame";
                type: "room_state";
                uuid: string;
            }
            | {
                error?: string;
                sourceMessage: | {
                    duration: number;
                    offset: number;
                    type: "progressbar_update";
                }
                | {
                    song: {
                        artist: string;
                        audioURL: string;
                        cover: string
                        | null;
                        hrefURL: string;
                        name: string;
                    };
                    startPos: number;
                    type: "player_pick_song";
                }
                | { answer?: string; answerIndex?: number; type: "select_answer" }
                | { type: "start_game" }
                | {
                    playlists: {
                        cover: string | null;
                        hrefURL: string;
                        name: string;
                        songs: {
                            artist: string;
                            audioURL: string;
                            cover: string | null;
                            hrefURL: string;
                            name: string;
                        }[];
                        subtitle?: string;
                    }[];
                    type: "add_playlists";
                }
                | { index: number
                | null; type: "remove_playlist" }
                | { type: "change_username"; username: string }
                | {
                    advancedSongFiltering: boolean;
                    allowChangingAnswer: boolean;
                    audioStartPosition: number | null;
                    distractionsPreferSameArtist: boolean;
                    endWhenAnswered: boolean;
                    gameMode: "multiple_choice" | "player_picks";
                    multipleChoiceAnswersCount: number;
                    playerPickTimeout: number;
                    roundsCount: number;
                    timePerQuestion: number;
                    type: "room_config";
                }
                | { playerName: string; type: "transfer_host" }
                | { type: "return_to"; where: "lobby" | "results" }
                | {
                    entry: LogEntry;
                    level: "error" | "info" | "warn" | "debug";
                    type: "add_log_message";
                }
                | { messages: LoggerStorage; type: "update_log_messages" }
                | {
                    gamePhase: GamePhase;
                    question?:
                        | {
                            answerOptions: string[];
                            correctAnswerIndex?: number;
                            questionType: "multiple_choice";
                            startPos: number;
                        }
                        | {
                            correctAnswer?: {
                                artist: string;
                                audioURL: string;
                                cover: string
                                | null;
                                hrefURL: string;
                                name: string;
                            };
                            pickerId: string;
                            questionCount: number;
                            questionCurrent: number;
                            questionType: "player_picks";
                            startPos: number;
                        };
                    roundCurrent: number;
                    type: "round_state";
                }
                | { action: "load"; audioURL: string; type: "audio_control" }
                | {
                    action:
                        | "play"
                        | "pause"
                        | "play_countdown_running"
                        | "play_countdown_end";
                    type: "audio_control";
                }
                | { countdown: number; type: "countdown" }
                | {
                    songs: {
                        artist: string;
                        audioURL: string;
                        cover: string | null;
                        hrefURL: string;
                        name: string;
                    }[];
                    type: "update_played_songs";
                }
                | {
                    filteredSongsCount: number;
                    playlists?: {
                        cover: string
                        | null;
                        hrefURL: string;
                        name: string;
                        songs: {
                            artist: string;
                            audioURL: string;
                            cover: string | null;
                            hrefURL: string;
                            name: string;
                        }[];
                        subtitle?: string;
                    }[];
                    type: "update_playlists";
                }
                | {
                    players: Record<
                        string,
                        {
                            answerData?: {
                                answer?: string;
                                answerIndex?: number;
                                answerSpeed?: number;
                                answerTimestamp?: number;
                                questionPoints: number;
                            };
                            color: string;
                            hasPicked?: boolean;
                            isHost: boolean;
                            isSpectator: boolean;
                            points: number;
                            username: string;
                            uuid: string;
                        },
                    >;
                    state: "lobby"
                    | "results"
                    | "ingame";
                    type: "room_state";
                    uuid: string;
                }
                | { type: "other" };
                type: "confirmation";
            }
            | { seq: number; type: "ping" }
            | { seq: number; type: "pong" }
            | null

        the received ServerMessage that caused the state change

        • { duration: number; offset: number; type: "progressbar_update" }
          • duration: number

            The duration of the progressbar.

          • offset: number

            The number of seconds to offset the progress bar start point.

          • type: "progressbar_update"
        • {
              advancedSongFiltering: boolean;
              allowChangingAnswer: boolean;
              audioStartPosition: number | null;
              distractionsPreferSameArtist: boolean;
              endWhenAnswered: boolean;
              gameMode: "multiple_choice" | "player_picks";
              multipleChoiceAnswersCount: number;
              playerPickTimeout: number;
              roundsCount: number;
              timePerQuestion: number;
              type: "room_config";
          }
          • advancedSongFiltering: boolean

            Whether to perform advanced filtering tactics when generating the songs array. Currently just ignores parens when filtering for identical song names.

          • allowChangingAnswer: boolean

            Whether to allow changing answer in multiple choice.

          • audioStartPosition: number | null

            The music start position for a game.

            Must be a float between

            • 0.0: start of audio

            and

            • 1.0: close to end of audio (audio duration minus max play time determined by config + round padding)

            Can be null to use random position (multiple choice) / let picker decide (player picks)

          • distractionsPreferSameArtist: boolean

            Whether to prefer distractions by the same artist.

          • endWhenAnswered: boolean

            Whether to directly end the round after all players answered.

          • gameMode: "multiple_choice" | "player_picks"

            The game mode being played.

            • multiple_choice: the server selects random songs from the provided playlist and provides a multiple choice question with distractions.
            • player_picks: a player from the room picks a song for other players to guess each round. other players have to guess the song title by typing.
          • multipleChoiceAnswersCount: number

            The amount of multiple choice answers to add.

          • playerPickTimeout: number

            The amount of time a player should have to pick a song.

          • roundsCount: number

            The amount of rounds to play.

          • timePerQuestion: number

            The time per question in each round.

          • type: "room_config"
        • {
              entry: LogEntry;
              level: "error" | "info" | "warn" | "debug";
              type: "add_log_message";
          }
          • entry: LogEntry

            The added log message.

          • level: "error" | "info" | "warn" | "debug"

            The log level of the added message.

          • type: "add_log_message"
        • { messages: LoggerStorage; type: "update_log_messages" }
        • {
              gamePhase: GamePhase;
              question?:
                  | {
                      answerOptions: string[];
                      correctAnswerIndex?: number;
                      questionType: "multiple_choice";
                      startPos: number;
                  }
                  | {
                      correctAnswer?: {
                          artist: string;
                          audioURL: string;
                          cover: string
                          | null;
                          hrefURL: string;
                          name: string;
                      };
                      pickerId: string;
                      questionCount: number;
                      questionCurrent: number;
                      questionType: "player_picks";
                      startPos: number;
                  };
              roundCurrent: number;
              type: "round_state";
          }
          • gamePhase: GamePhase

            The current game phase.

            GamePhase

          • Optionalquestion?:
                | {
                    answerOptions: string[];
                    correctAnswerIndex?: number;
                    questionType: "multiple_choice";
                    startPos: number;
                }
                | {
                    correctAnswer?: {
                        artist: string;
                        audioURL: string;
                        cover: string
                        | null;
                        hrefURL: string;
                        name: string;
                    };
                    pickerId: string;
                    questionCount: number;
                    questionCurrent: number;
                    questionType: "player_picks";
                    startPos: number;
                }
          • roundCurrent: number

            The round number.

          • type: "round_state"
        • { action: "load"; audioURL: string; type: "audio_control" }
          • action: "load"
            • "load": Downloads the music.
          • audioURL: string

            URL to load music from.

          • type: "audio_control"
        • {
              action:
                  | "play"
                  | "pause"
                  | "play_countdown_running"
                  | "play_countdown_end";
              type: "audio_control";
          }
          • action: "play" | "pause" | "play_countdown_running" | "play_countdown_end"
            • "play": Starts playback of the music.
            • "pause": Pauses playback of the music.
            • "play_countdown_running": Plays the countdown_running sound effect on a secondary audio player.
            • "play_countdown_end": Plays the countdown_end sound effect on a secondary audio player.
          • type: "audio_control"
        • { countdown: number; type: "countdown" }
          • countdown: number

            The current countdown number. 0 to hide.

          • type: "countdown"
        • {
              songs: {
                  artist: string;
                  audioURL: string;
                  cover: string | null;
                  hrefURL: string;
                  name: string;
              }[];
              type: "update_played_songs";
          }
          • songs: {
                artist: string;
                audioURL: string;
                cover: string | null;
                hrefURL: string;
                name: string;
            }[]

            The songs that were played in this round.

          • type: "update_played_songs"
        • {
              filteredSongsCount: number;
              playlists?: {
                  cover: string | null;
                  hrefURL: string;
                  name: string;
                  songs: {
                      artist: string;
                      audioURL: string;
                      cover: string | null;
                      hrefURL: string;
                      name: string;
                  }[];
                  subtitle?: string;
              }[];
              type: "update_playlists";
          }
          • filteredSongsCount: number

            The count of filtered songs.

            filterSongs

          • Optionalplaylists?: {
                cover: string | null;
                hrefURL: string;
                name: string;
                songs: {
                    artist: string;
                    audioURL: string;
                    cover: string | null;
                    hrefURL: string;
                    name: string;
                }[];
                subtitle?: string;
            }[]

            Currently selected playlist(s)

          • type: "update_playlists"
        • {
              players: Record<
                  string,
                  {
                      answerData?: {
                          answer?: string;
                          answerIndex?: number;
                          answerSpeed?: number;
                          answerTimestamp?: number;
                          questionPoints: number;
                      };
                      color: string;
                      hasPicked?: boolean;
                      isHost: boolean;
                      isSpectator: boolean;
                      points: number;
                      username: string;
                      uuid: string;
                  },
              >;
              state: "lobby"
              | "results"
              | "ingame";
              type: "room_state";
              uuid: string;
          }
          • players: Record<
                string,
                {
                    answerData?: {
                        answer?: string;
                        answerIndex?: number;
                        answerSpeed?: number;
                        answerTimestamp?: number;
                        questionPoints: number;
                    };
                    color: string;
                    hasPicked?: boolean;
                    isHost: boolean;
                    isSpectator: boolean;
                    points: number;
                    username: string;
                    uuid: string;
                },
            >

            A map of all active (online, non-spectating) players. Key is server generated uuid, NOT connection id.

          • state: "lobby" | "results" | "ingame"

            The current game state

          • type: "room_state"
          • uuid: string

            The player's unique identifier generated by the server. Not connection id!

        • {
              error?: string;
              sourceMessage:
                  | { duration: number; offset: number; type: "progressbar_update" }
                  | {
                      song: {
                          artist: string;
                          audioURL: string;
                          cover: string | null;
                          hrefURL: string;
                          name: string;
                      };
                      startPos: number;
                      type: "player_pick_song";
                  }
                  | { answer?: string; answerIndex?: number; type: "select_answer" }
                  | { type: "start_game" }
                  | {
                      playlists: {
                          cover: string | null;
                          hrefURL: string;
                          name: string;
                          songs: {
                              artist: string;
                              audioURL: string;
                              cover: string | null;
                              hrefURL: string;
                              name: string;
                          }[];
                          subtitle?: string;
                      }[];
                      type: "add_playlists";
                  }
                  | { index: number
                  | null; type: "remove_playlist" }
                  | { type: "change_username"; username: string }
                  | {
                      advancedSongFiltering: boolean;
                      allowChangingAnswer: boolean;
                      audioStartPosition: number | null;
                      distractionsPreferSameArtist: boolean;
                      endWhenAnswered: boolean;
                      gameMode: "multiple_choice" | "player_picks";
                      multipleChoiceAnswersCount: number;
                      playerPickTimeout: number;
                      roundsCount: number;
                      timePerQuestion: number;
                      type: "room_config";
                  }
                  | { playerName: string; type: "transfer_host" }
                  | { type: "return_to"; where: "lobby" | "results" }
                  | {
                      entry: LogEntry;
                      level: "error" | "info" | "warn" | "debug";
                      type: "add_log_message";
                  }
                  | { messages: LoggerStorage; type: "update_log_messages" }
                  | {
                      gamePhase: GamePhase;
                      question?:
                          | {
                              answerOptions: string[];
                              correctAnswerIndex?: number;
                              questionType: "multiple_choice";
                              startPos: number;
                          }
                          | {
                              correctAnswer?: {
                                  artist: string;
                                  audioURL: string;
                                  cover: string
                                  | null;
                                  hrefURL: string;
                                  name: string;
                              };
                              pickerId: string;
                              questionCount: number;
                              questionCurrent: number;
                              questionType: "player_picks";
                              startPos: number;
                          };
                      roundCurrent: number;
                      type: "round_state";
                  }
                  | { action: "load"; audioURL: string; type: "audio_control" }
                  | {
                      action:
                          | "play"
                          | "pause"
                          | "play_countdown_running"
                          | "play_countdown_end";
                      type: "audio_control";
                  }
                  | { countdown: number; type: "countdown" }
                  | {
                      songs: {
                          artist: string;
                          audioURL: string;
                          cover: string | null;
                          hrefURL: string;
                          name: string;
                      }[];
                      type: "update_played_songs";
                  }
                  | {
                      filteredSongsCount: number;
                      playlists?: {
                          cover: string
                          | null;
                          hrefURL: string;
                          name: string;
                          songs: {
                              artist: string;
                              audioURL: string;
                              cover: string | null;
                              hrefURL: string;
                              name: string;
                          }[];
                          subtitle?: string;
                      }[];
                      type: "update_playlists";
                  }
                  | {
                      players: Record<
                          string,
                          {
                              answerData?: {
                                  answer?: string;
                                  answerIndex?: number;
                                  answerSpeed?: number;
                                  answerTimestamp?: number;
                                  questionPoints: number;
                              };
                              color: string;
                              hasPicked?: boolean;
                              isHost: boolean;
                              isSpectator: boolean;
                              points: number;
                              username: string;
                              uuid: string;
                          },
                      >;
                      state: "lobby"
                      | "results"
                      | "ingame";
                      type: "room_state";
                      uuid: string;
                  }
                  | { type: "other" };
              type: "confirmation";
          }
          • Optionalerror?: string

            Optional error message if the requested action could not be performed.

          • sourceMessage:
                | { duration: number; offset: number; type: "progressbar_update" }
                | {
                    song: {
                        artist: string;
                        audioURL: string;
                        cover: string | null;
                        hrefURL: string;
                        name: string;
                    };
                    startPos: number;
                    type: "player_pick_song";
                }
                | { answer?: string; answerIndex?: number; type: "select_answer" }
                | { type: "start_game" }
                | {
                    playlists: {
                        cover: string | null;
                        hrefURL: string;
                        name: string;
                        songs: {
                            artist: string;
                            audioURL: string;
                            cover: string | null;
                            hrefURL: string;
                            name: string;
                        }[];
                        subtitle?: string;
                    }[];
                    type: "add_playlists";
                }
                | { index: number
                | null; type: "remove_playlist" }
                | { type: "change_username"; username: string }
                | {
                    advancedSongFiltering: boolean;
                    allowChangingAnswer: boolean;
                    audioStartPosition: number | null;
                    distractionsPreferSameArtist: boolean;
                    endWhenAnswered: boolean;
                    gameMode: "multiple_choice" | "player_picks";
                    multipleChoiceAnswersCount: number;
                    playerPickTimeout: number;
                    roundsCount: number;
                    timePerQuestion: number;
                    type: "room_config";
                }
                | { playerName: string; type: "transfer_host" }
                | { type: "return_to"; where: "lobby" | "results" }
                | {
                    entry: LogEntry;
                    level: "error" | "info" | "warn" | "debug";
                    type: "add_log_message";
                }
                | { messages: LoggerStorage; type: "update_log_messages" }
                | {
                    gamePhase: GamePhase;
                    question?:
                        | {
                            answerOptions: string[];
                            correctAnswerIndex?: number;
                            questionType: "multiple_choice";
                            startPos: number;
                        }
                        | {
                            correctAnswer?: {
                                artist: string;
                                audioURL: string;
                                cover: string
                                | null;
                                hrefURL: string;
                                name: string;
                            };
                            pickerId: string;
                            questionCount: number;
                            questionCurrent: number;
                            questionType: "player_picks";
                            startPos: number;
                        };
                    roundCurrent: number;
                    type: "round_state";
                }
                | { action: "load"; audioURL: string; type: "audio_control" }
                | {
                    action:
                        | "play"
                        | "pause"
                        | "play_countdown_running"
                        | "play_countdown_end";
                    type: "audio_control";
                }
                | { countdown: number; type: "countdown" }
                | {
                    songs: {
                        artist: string;
                        audioURL: string;
                        cover: string | null;
                        hrefURL: string;
                        name: string;
                    }[];
                    type: "update_played_songs";
                }
                | {
                    filteredSongsCount: number;
                    playlists?: {
                        cover: string
                        | null;
                        hrefURL: string;
                        name: string;
                        songs: {
                            artist: string;
                            audioURL: string;
                            cover: string | null;
                            hrefURL: string;
                            name: string;
                        }[];
                        subtitle?: string;
                    }[];
                    type: "update_playlists";
                }
                | {
                    players: Record<
                        string,
                        {
                            answerData?: {
                                answer?: string;
                                answerIndex?: number;
                                answerSpeed?: number;
                                answerTimestamp?: number;
                                questionPoints: number;
                            };
                            color: string;
                            hasPicked?: boolean;
                            isHost: boolean;
                            isSpectator: boolean;
                            points: number;
                            username: string;
                            uuid: string;
                        },
                    >;
                    state: "lobby"
                    | "results"
                    | "ingame";
                    type: "room_state";
                    uuid: string;
                }
                | { type: "other" }

            The message that is being confirmed.

          • type: "confirmation"
        • { seq: number; type: "ping" }
          • seq: number

            The sequence number the pong should respond with

          • type: "ping"
        • { seq: number; type: "pong" }
          • seq: number

            The sequence number asked for in the ping packet.

          • type: "pong"
        • null

      Returns void

    • Whether the current question in player picks was selected by the provided uuid.

      Parameters

      • uuid: string

        the uuid to check.

      Returns boolean

      true if the game mode is player picks and the current round message pickerId matches the provided uuid.

    • Cleans up resources.

      Parameters

      • closeSocket: boolean

        whether to also close the socket connection.

      Returns void

    • Private

      Handles a message sent from the server.

      Parameters

      • msg:
            | { duration: number; offset: number; type: "progressbar_update" }
            | {
                advancedSongFiltering: boolean;
                allowChangingAnswer: boolean;
                audioStartPosition: number | null;
                distractionsPreferSameArtist: boolean;
                endWhenAnswered: boolean;
                gameMode: "multiple_choice" | "player_picks";
                multipleChoiceAnswersCount: number;
                playerPickTimeout: number;
                roundsCount: number;
                timePerQuestion: number;
                type: "room_config";
            }
            | {
                entry: LogEntry;
                level: "error"
                | "info"
                | "warn"
                | "debug";
                type: "add_log_message";
            }
            | { messages: LoggerStorage; type: "update_log_messages" }
            | {
                gamePhase: GamePhase;
                question?:
                    | {
                        answerOptions: string[];
                        correctAnswerIndex?: number;
                        questionType: "multiple_choice";
                        startPos: number;
                    }
                    | {
                        correctAnswer?: {
                            artist: string;
                            audioURL: string;
                            cover: string
                            | null;
                            hrefURL: string;
                            name: string;
                        };
                        pickerId: string;
                        questionCount: number;
                        questionCurrent: number;
                        questionType: "player_picks";
                        startPos: number;
                    };
                roundCurrent: number;
                type: "round_state";
            }
            | { action: "load"; audioURL: string; type: "audio_control" }
            | {
                action:
                    | "play"
                    | "pause"
                    | "play_countdown_running"
                    | "play_countdown_end";
                type: "audio_control";
            }
            | { countdown: number; type: "countdown" }
            | {
                songs: {
                    artist: string;
                    audioURL: string;
                    cover: string | null;
                    hrefURL: string;
                    name: string;
                }[];
                type: "update_played_songs";
            }
            | {
                filteredSongsCount: number;
                playlists?: {
                    cover: string
                    | null;
                    hrefURL: string;
                    name: string;
                    songs: {
                        artist: string;
                        audioURL: string;
                        cover: string | null;
                        hrefURL: string;
                        name: string;
                    }[];
                    subtitle?: string;
                }[];
                type: "update_playlists";
            }
            | {
                players: Record<
                    string,
                    {
                        answerData?: {
                            answer?: string;
                            answerIndex?: number;
                            answerSpeed?: number;
                            answerTimestamp?: number;
                            questionPoints: number;
                        };
                        color: string;
                        hasPicked?: boolean;
                        isHost: boolean;
                        isSpectator: boolean;
                        points: number;
                        username: string;
                        uuid: string;
                    },
                >;
                state: "lobby"
                | "results"
                | "ingame";
                type: "room_state";
                uuid: string;
            }
            | {
                error?: string;
                sourceMessage: | {
                    duration: number;
                    offset: number;
                    type: "progressbar_update";
                }
                | {
                    song: {
                        artist: string;
                        audioURL: string;
                        cover: string
                        | null;
                        hrefURL: string;
                        name: string;
                    };
                    startPos: number;
                    type: "player_pick_song";
                }
                | { answer?: string; answerIndex?: number; type: "select_answer" }
                | { type: "start_game" }
                | {
                    playlists: {
                        cover: string | null;
                        hrefURL: string;
                        name: string;
                        songs: {
                            artist: string;
                            audioURL: string;
                            cover: string | null;
                            hrefURL: string;
                            name: string;
                        }[];
                        subtitle?: string;
                    }[];
                    type: "add_playlists";
                }
                | { index: number
                | null; type: "remove_playlist" }
                | { type: "change_username"; username: string }
                | {
                    advancedSongFiltering: boolean;
                    allowChangingAnswer: boolean;
                    audioStartPosition: number | null;
                    distractionsPreferSameArtist: boolean;
                    endWhenAnswered: boolean;
                    gameMode: "multiple_choice" | "player_picks";
                    multipleChoiceAnswersCount: number;
                    playerPickTimeout: number;
                    roundsCount: number;
                    timePerQuestion: number;
                    type: "room_config";
                }
                | { playerName: string; type: "transfer_host" }
                | { type: "return_to"; where: "lobby" | "results" }
                | {
                    entry: LogEntry;
                    level: "error" | "info" | "warn" | "debug";
                    type: "add_log_message";
                }
                | { messages: LoggerStorage; type: "update_log_messages" }
                | {
                    gamePhase: GamePhase;
                    question?:
                        | {
                            answerOptions: string[];
                            correctAnswerIndex?: number;
                            questionType: "multiple_choice";
                            startPos: number;
                        }
                        | {
                            correctAnswer?: {
                                artist: string;
                                audioURL: string;
                                cover: string
                                | null;
                                hrefURL: string;
                                name: string;
                            };
                            pickerId: string;
                            questionCount: number;
                            questionCurrent: number;
                            questionType: "player_picks";
                            startPos: number;
                        };
                    roundCurrent: number;
                    type: "round_state";
                }
                | { action: "load"; audioURL: string; type: "audio_control" }
                | {
                    action:
                        | "play"
                        | "pause"
                        | "play_countdown_running"
                        | "play_countdown_end";
                    type: "audio_control";
                }
                | { countdown: number; type: "countdown" }
                | {
                    songs: {
                        artist: string;
                        audioURL: string;
                        cover: string | null;
                        hrefURL: string;
                        name: string;
                    }[];
                    type: "update_played_songs";
                }
                | {
                    filteredSongsCount: number;
                    playlists?: {
                        cover: string
                        | null;
                        hrefURL: string;
                        name: string;
                        songs: {
                            artist: string;
                            audioURL: string;
                            cover: string | null;
                            hrefURL: string;
                            name: string;
                        }[];
                        subtitle?: string;
                    }[];
                    type: "update_playlists";
                }
                | {
                    players: Record<
                        string,
                        {
                            answerData?: {
                                answer?: string;
                                answerIndex?: number;
                                answerSpeed?: number;
                                answerTimestamp?: number;
                                questionPoints: number;
                            };
                            color: string;
                            hasPicked?: boolean;
                            isHost: boolean;
                            isSpectator: boolean;
                            points: number;
                            username: string;
                            uuid: string;
                        },
                    >;
                    state: "lobby"
                    | "results"
                    | "ingame";
                    type: "room_state";
                    uuid: string;
                }
                | { type: "other" };
                type: "confirmation";
            }
            | { seq: number; type: "ping" }
            | { seq: number; type: "pong" }

        the message the server sent.

        • { duration: number; offset: number; type: "progressbar_update" }
          • duration: number

            The duration of the progressbar.

          • offset: number

            The number of seconds to offset the progress bar start point.

          • type: "progressbar_update"
        • {
              advancedSongFiltering: boolean;
              allowChangingAnswer: boolean;
              audioStartPosition: number | null;
              distractionsPreferSameArtist: boolean;
              endWhenAnswered: boolean;
              gameMode: "multiple_choice" | "player_picks";
              multipleChoiceAnswersCount: number;
              playerPickTimeout: number;
              roundsCount: number;
              timePerQuestion: number;
              type: "room_config";
          }
          • advancedSongFiltering: boolean

            Whether to perform advanced filtering tactics when generating the songs array. Currently just ignores parens when filtering for identical song names.

          • allowChangingAnswer: boolean

            Whether to allow changing answer in multiple choice.

          • audioStartPosition: number | null

            The music start position for a game.

            Must be a float between

            • 0.0: start of audio

            and

            • 1.0: close to end of audio (audio duration minus max play time determined by config + round padding)

            Can be null to use random position (multiple choice) / let picker decide (player picks)

          • distractionsPreferSameArtist: boolean

            Whether to prefer distractions by the same artist.

          • endWhenAnswered: boolean

            Whether to directly end the round after all players answered.

          • gameMode: "multiple_choice" | "player_picks"

            The game mode being played.

            • multiple_choice: the server selects random songs from the provided playlist and provides a multiple choice question with distractions.
            • player_picks: a player from the room picks a song for other players to guess each round. other players have to guess the song title by typing.
          • multipleChoiceAnswersCount: number

            The amount of multiple choice answers to add.

          • playerPickTimeout: number

            The amount of time a player should have to pick a song.

          • roundsCount: number

            The amount of rounds to play.

          • timePerQuestion: number

            The time per question in each round.

          • type: "room_config"
        • {
              entry: LogEntry;
              level: "error" | "info" | "warn" | "debug";
              type: "add_log_message";
          }
          • entry: LogEntry

            The added log message.

          • level: "error" | "info" | "warn" | "debug"

            The log level of the added message.

          • type: "add_log_message"
        • { messages: LoggerStorage; type: "update_log_messages" }
        • {
              gamePhase: GamePhase;
              question?:
                  | {
                      answerOptions: string[];
                      correctAnswerIndex?: number;
                      questionType: "multiple_choice";
                      startPos: number;
                  }
                  | {
                      correctAnswer?: {
                          artist: string;
                          audioURL: string;
                          cover: string
                          | null;
                          hrefURL: string;
                          name: string;
                      };
                      pickerId: string;
                      questionCount: number;
                      questionCurrent: number;
                      questionType: "player_picks";
                      startPos: number;
                  };
              roundCurrent: number;
              type: "round_state";
          }
          • gamePhase: GamePhase

            The current game phase.

            GamePhase

          • Optionalquestion?:
                | {
                    answerOptions: string[];
                    correctAnswerIndex?: number;
                    questionType: "multiple_choice";
                    startPos: number;
                }
                | {
                    correctAnswer?: {
                        artist: string;
                        audioURL: string;
                        cover: string
                        | null;
                        hrefURL: string;
                        name: string;
                    };
                    pickerId: string;
                    questionCount: number;
                    questionCurrent: number;
                    questionType: "player_picks";
                    startPos: number;
                }
          • roundCurrent: number

            The round number.

          • type: "round_state"
        • { action: "load"; audioURL: string; type: "audio_control" }
          • action: "load"
            • "load": Downloads the music.
          • audioURL: string

            URL to load music from.

          • type: "audio_control"
        • {
              action:
                  | "play"
                  | "pause"
                  | "play_countdown_running"
                  | "play_countdown_end";
              type: "audio_control";
          }
          • action: "play" | "pause" | "play_countdown_running" | "play_countdown_end"
            • "play": Starts playback of the music.
            • "pause": Pauses playback of the music.
            • "play_countdown_running": Plays the countdown_running sound effect on a secondary audio player.
            • "play_countdown_end": Plays the countdown_end sound effect on a secondary audio player.
          • type: "audio_control"
        • { countdown: number; type: "countdown" }
          • countdown: number

            The current countdown number. 0 to hide.

          • type: "countdown"
        • {
              songs: {
                  artist: string;
                  audioURL: string;
                  cover: string | null;
                  hrefURL: string;
                  name: string;
              }[];
              type: "update_played_songs";
          }
          • songs: {
                artist: string;
                audioURL: string;
                cover: string | null;
                hrefURL: string;
                name: string;
            }[]

            The songs that were played in this round.

          • type: "update_played_songs"
        • {
              filteredSongsCount: number;
              playlists?: {
                  cover: string | null;
                  hrefURL: string;
                  name: string;
                  songs: {
                      artist: string;
                      audioURL: string;
                      cover: string | null;
                      hrefURL: string;
                      name: string;
                  }[];
                  subtitle?: string;
              }[];
              type: "update_playlists";
          }
          • filteredSongsCount: number

            The count of filtered songs.

            filterSongs

          • Optionalplaylists?: {
                cover: string | null;
                hrefURL: string;
                name: string;
                songs: {
                    artist: string;
                    audioURL: string;
                    cover: string | null;
                    hrefURL: string;
                    name: string;
                }[];
                subtitle?: string;
            }[]

            Currently selected playlist(s)

          • type: "update_playlists"
        • {
              players: Record<
                  string,
                  {
                      answerData?: {
                          answer?: string;
                          answerIndex?: number;
                          answerSpeed?: number;
                          answerTimestamp?: number;
                          questionPoints: number;
                      };
                      color: string;
                      hasPicked?: boolean;
                      isHost: boolean;
                      isSpectator: boolean;
                      points: number;
                      username: string;
                      uuid: string;
                  },
              >;
              state: "lobby"
              | "results"
              | "ingame";
              type: "room_state";
              uuid: string;
          }
          • players: Record<
                string,
                {
                    answerData?: {
                        answer?: string;
                        answerIndex?: number;
                        answerSpeed?: number;
                        answerTimestamp?: number;
                        questionPoints: number;
                    };
                    color: string;
                    hasPicked?: boolean;
                    isHost: boolean;
                    isSpectator: boolean;
                    points: number;
                    username: string;
                    uuid: string;
                },
            >

            A map of all active (online, non-spectating) players. Key is server generated uuid, NOT connection id.

          • state: "lobby" | "results" | "ingame"

            The current game state

          • type: "room_state"
          • uuid: string

            The player's unique identifier generated by the server. Not connection id!

        • {
              error?: string;
              sourceMessage:
                  | { duration: number; offset: number; type: "progressbar_update" }
                  | {
                      song: {
                          artist: string;
                          audioURL: string;
                          cover: string | null;
                          hrefURL: string;
                          name: string;
                      };
                      startPos: number;
                      type: "player_pick_song";
                  }
                  | { answer?: string; answerIndex?: number; type: "select_answer" }
                  | { type: "start_game" }
                  | {
                      playlists: {
                          cover: string | null;
                          hrefURL: string;
                          name: string;
                          songs: {
                              artist: string;
                              audioURL: string;
                              cover: string | null;
                              hrefURL: string;
                              name: string;
                          }[];
                          subtitle?: string;
                      }[];
                      type: "add_playlists";
                  }
                  | { index: number
                  | null; type: "remove_playlist" }
                  | { type: "change_username"; username: string }
                  | {
                      advancedSongFiltering: boolean;
                      allowChangingAnswer: boolean;
                      audioStartPosition: number | null;
                      distractionsPreferSameArtist: boolean;
                      endWhenAnswered: boolean;
                      gameMode: "multiple_choice" | "player_picks";
                      multipleChoiceAnswersCount: number;
                      playerPickTimeout: number;
                      roundsCount: number;
                      timePerQuestion: number;
                      type: "room_config";
                  }
                  | { playerName: string; type: "transfer_host" }
                  | { type: "return_to"; where: "lobby" | "results" }
                  | {
                      entry: LogEntry;
                      level: "error" | "info" | "warn" | "debug";
                      type: "add_log_message";
                  }
                  | { messages: LoggerStorage; type: "update_log_messages" }
                  | {
                      gamePhase: GamePhase;
                      question?:
                          | {
                              answerOptions: string[];
                              correctAnswerIndex?: number;
                              questionType: "multiple_choice";
                              startPos: number;
                          }
                          | {
                              correctAnswer?: {
                                  artist: string;
                                  audioURL: string;
                                  cover: string
                                  | null;
                                  hrefURL: string;
                                  name: string;
                              };
                              pickerId: string;
                              questionCount: number;
                              questionCurrent: number;
                              questionType: "player_picks";
                              startPos: number;
                          };
                      roundCurrent: number;
                      type: "round_state";
                  }
                  | { action: "load"; audioURL: string; type: "audio_control" }
                  | {
                      action:
                          | "play"
                          | "pause"
                          | "play_countdown_running"
                          | "play_countdown_end";
                      type: "audio_control";
                  }
                  | { countdown: number; type: "countdown" }
                  | {
                      songs: {
                          artist: string;
                          audioURL: string;
                          cover: string | null;
                          hrefURL: string;
                          name: string;
                      }[];
                      type: "update_played_songs";
                  }
                  | {
                      filteredSongsCount: number;
                      playlists?: {
                          cover: string
                          | null;
                          hrefURL: string;
                          name: string;
                          songs: {
                              artist: string;
                              audioURL: string;
                              cover: string | null;
                              hrefURL: string;
                              name: string;
                          }[];
                          subtitle?: string;
                      }[];
                      type: "update_playlists";
                  }
                  | {
                      players: Record<
                          string,
                          {
                              answerData?: {
                                  answer?: string;
                                  answerIndex?: number;
                                  answerSpeed?: number;
                                  answerTimestamp?: number;
                                  questionPoints: number;
                              };
                              color: string;
                              hasPicked?: boolean;
                              isHost: boolean;
                              isSpectator: boolean;
                              points: number;
                              username: string;
                              uuid: string;
                          },
                      >;
                      state: "lobby"
                      | "results"
                      | "ingame";
                      type: "room_state";
                      uuid: string;
                  }
                  | { type: "other" };
              type: "confirmation";
          }
          • Optionalerror?: string

            Optional error message if the requested action could not be performed.

          • sourceMessage:
                | { duration: number; offset: number; type: "progressbar_update" }
                | {
                    song: {
                        artist: string;
                        audioURL: string;
                        cover: string | null;
                        hrefURL: string;
                        name: string;
                    };
                    startPos: number;
                    type: "player_pick_song";
                }
                | { answer?: string; answerIndex?: number; type: "select_answer" }
                | { type: "start_game" }
                | {
                    playlists: {
                        cover: string | null;
                        hrefURL: string;
                        name: string;
                        songs: {
                            artist: string;
                            audioURL: string;
                            cover: string | null;
                            hrefURL: string;
                            name: string;
                        }[];
                        subtitle?: string;
                    }[];
                    type: "add_playlists";
                }
                | { index: number
                | null; type: "remove_playlist" }
                | { type: "change_username"; username: string }
                | {
                    advancedSongFiltering: boolean;
                    allowChangingAnswer: boolean;
                    audioStartPosition: number | null;
                    distractionsPreferSameArtist: boolean;
                    endWhenAnswered: boolean;
                    gameMode: "multiple_choice" | "player_picks";
                    multipleChoiceAnswersCount: number;
                    playerPickTimeout: number;
                    roundsCount: number;
                    timePerQuestion: number;
                    type: "room_config";
                }
                | { playerName: string; type: "transfer_host" }
                | { type: "return_to"; where: "lobby" | "results" }
                | {
                    entry: LogEntry;
                    level: "error" | "info" | "warn" | "debug";
                    type: "add_log_message";
                }
                | { messages: LoggerStorage; type: "update_log_messages" }
                | {
                    gamePhase: GamePhase;
                    question?:
                        | {
                            answerOptions: string[];
                            correctAnswerIndex?: number;
                            questionType: "multiple_choice";
                            startPos: number;
                        }
                        | {
                            correctAnswer?: {
                                artist: string;
                                audioURL: string;
                                cover: string
                                | null;
                                hrefURL: string;
                                name: string;
                            };
                            pickerId: string;
                            questionCount: number;
                            questionCurrent: number;
                            questionType: "player_picks";
                            startPos: number;
                        };
                    roundCurrent: number;
                    type: "round_state";
                }
                | { action: "load"; audioURL: string; type: "audio_control" }
                | {
                    action:
                        | "play"
                        | "pause"
                        | "play_countdown_running"
                        | "play_countdown_end";
                    type: "audio_control";
                }
                | { countdown: number; type: "countdown" }
                | {
                    songs: {
                        artist: string;
                        audioURL: string;
                        cover: string | null;
                        hrefURL: string;
                        name: string;
                    }[];
                    type: "update_played_songs";
                }
                | {
                    filteredSongsCount: number;
                    playlists?: {
                        cover: string
                        | null;
                        hrefURL: string;
                        name: string;
                        songs: {
                            artist: string;
                            audioURL: string;
                            cover: string | null;
                            hrefURL: string;
                            name: string;
                        }[];
                        subtitle?: string;
                    }[];
                    type: "update_playlists";
                }
                | {
                    players: Record<
                        string,
                        {
                            answerData?: {
                                answer?: string;
                                answerIndex?: number;
                                answerSpeed?: number;
                                answerTimestamp?: number;
                                questionPoints: number;
                            };
                            color: string;
                            hasPicked?: boolean;
                            isHost: boolean;
                            isSpectator: boolean;
                            points: number;
                            username: string;
                            uuid: string;
                        },
                    >;
                    state: "lobby"
                    | "results"
                    | "ingame";
                    type: "room_state";
                    uuid: string;
                }
                | { type: "other" }

            The message that is being confirmed.

          • type: "confirmation"
        • { seq: number; type: "ping" }
          • seq: number

            The sequence number the pong should respond with

          • type: "ping"
        • { seq: number; type: "pong" }
          • seq: number

            The sequence number asked for in the ping packet.

          • type: "pong"

      Returns void

    • Imports playlists from a validated PlaylistsFile object.

      Parameters

      • playlistsFile: {
            playlists: {
                cover: string | null;
                hrefURL: string;
                name: string;
                songs: {
                    artist: string;
                    audioURL: string;
                    cover: string | null;
                    hrefURL: string;
                    name: string;
                }[];
                subtitle?: string;
            }[];
            version: "1.0";
        }

        The validated PlaylistsFile object containing playlist data.

        • playlists: {
              cover: string | null;
              hrefURL: string;
              name: string;
              songs: {
                  artist: string;
                  audioURL: string;
                  cover: string | null;
                  hrefURL: string;
                  name: string;
              }[];
              subtitle?: string;
          }[]

          The playlists of this export.

        • version: "1.0"

          Version of this export. Only used for validation.

      Returns void

    • Handles the "close" event of the socket connection.

      Parameters

      • ev: CloseEvent

        The CloseEvent containing details about the disconnection.

      Returns void

    • Handles the "error" event of the socket connection.

      Parameters

      • ev: ErrorEvent

        The ErrorEvent containing details about the error.

      Returns void

    • Handles incoming messages from the server.

      Parameters

      • ev: MessageEvent

        The MessageEvent containing the server message.

      Returns void

    • Sends the picked song to the server for PlayerPicksGame.

      Parameters

      • song: {
            artist: string;
            audioURL: string;
            cover: string | null;
            hrefURL: string;
            name: string;
        }

        The song the player picked.

        • artist: string

          The name of the song artist.

        • audioURL: string

          A URL to the audio file of the song. Currently only audio previews from Apple Music, SoundCloud and YT are allowed.

        • cover: string | null

          Cover URL of the song.

        • hrefURL: string

          The URL users will be redirected to when clicking.

        • name: string

          The name of the song.

      • startPos: number

        The start position for the audio.

      Returns void

    • (Re)connect to the PartyKit server with options.

      Parameters

      • newUsername: string | null

        if this is null, request a new username when reconnecting.

      • spectate: boolean = false

        whether the player wants to spectate the game.

      Returns void

    • Requests the server to remove a playlist from the list.

      Parameters

      • index: number | null

        the index of the playlist to remove. null to remove all playlists.

      Returns void

    • Sends the selected answer to the server for MultipleChoiceGame.

      Parameters

      • answerIndex: number

        The index of the selected answer (0-3).

      Returns void

    • Sends the text answer (song guess) to the server for PlayerPicksGame.

      Parameters

      • answer: string

        The song name the player guessed.

      Returns void

    • Requests a host transfer from the server.

      Parameters

      • player: string

        The name of the player that should get host.

      Returns void

    • Updates the username of the current player.

      Parameters

      • newName: string

        The new username to set.

      Returns void