The GameRoomClient class extends the BaseClient and provides functionality for interacting with a game room server. It manages the state of the game room, handles WebSocket events, and provides methods for creating, joining, and managing game rooms and seats.

Hierarchy

  • BaseClient
    • GameRoomClient

Implements

Constructors

Properties

client: IClient
connectionStore: Store<ConnectionState>

The store that tracks the connection state (disconnected, autoreconnecting, tries to connect).

gameId: undefined | number

The ID of the current game room.

gamePassword: undefined | string

The password for the current game room, if applicable.

signalConnections: SignalConnection[] = []
store: Store<GameRoomState>

The Redux-like store that manages the state of the game room.

userInfo: undefined | UserInfo

Information about the current user.

Methods

  • Parameters

    • connection: SignalConnection

    Returns SignalConnection

  • Creates a new game room.

    Parameters

    • game: string

      The id of the game.

    • options: GameOptions

      The options for the game room.

    Returns Promise<[number, undefined | string]>

    A promise that resolves to a tuple containing the game room ID and password.

  • Checks if the current user currecntly occupies a specific seat.

    Parameters

    • index: number

      The index of the seat to check.

    Returns boolean

    true if the user can occupy the seat, otherwise false.

  • Joins an existing game room.

    Parameters

    • gameId: number

      The ID of the game room to join.

    • Optionalpassword: string

      The password for the game room, if required.

    Returns Promise<number>

    A promise that resolves to the game room ID.

  • Parameters

    • method: () => void

    Returns SignalConnection

  • Parameters

    • method: () => void

    Returns SignalConnection

  • Parameters

    • name: string
    • method: (...args: any[]) => void

    Returns void

  • Starts the client by connecting to the server and authorizing the user.

    Parameters

    • token: string

      The authorization token for the user.

    Returns Promise<boolean>

    A promise that resolves to true if the client started successfully, otherwise false.