@game-vir/multiplayer - v15.1.1
    Preparing search index...

    Class MultiplayerController<Action>

    An all-in-one controller for singleplayer or lock-step multiplayer game state. Singleplayer mode requires no servers. Multiplayer mode requires a backend service running the MultiplayerApi.

    Type Parameters

    • Action extends JsonCompatibleValue = any

    Hierarchy

    Index

    Constructors

    Properties

    currentConnection: undefined | LockStepGameStateController<any>

    Current WebRTC lock step connection with the room host (when not the host) or all room participants (when the host). This will only be initialized after calling MultiplayerController.joinOrCreateRoom.

    enableRoomUpdates: boolean = true

    Set to false to disable room updates, even when still not connected to a room in multiplayer mode.

    events: {
        ControllerClientEvent: typeof ControllerClientEvent;
        ControllerConnectionEvent: typeof ControllerConnectionEvent;
        ControllerFrameEvent: typeof ControllerFrameEvent;
        ControllerRoomListEvent: typeof ControllerRoomListEvent;
    } = MultiplayerController.events

    All events emitted by this controller.

    knownErrors: { RoomRejectionError: typeof RoomRejectionError } = MultiplayerController.knownErrors
    multiplayerApi:
        | undefined
        | Promise<
            RestVirApi<
                ServiceDefinition<
                    "multiplayer-service",
                    {
                        "/": {
                            methods: { GET: true };
                            requestDataShape: undefined;
                            requiredClientOrigin: {};
                            responseDataShape: ShapeExact<readonly ["ok"]>;
                        };
                        "/health": {
                            methods: { GET: true };
                            requestDataShape: undefined;
                            requiredClientOrigin: {};
                            responseDataShape: ShapeExact<readonly ["ok"]>;
                        };
                        "/rooms": {
                            methods: { GET: true };
                            requestDataShape: undefined;
                            responseDataShape: ShapeDefinition<
                                ShapeIndexedKeys<
                                    [
                                        {
                                            keys: CustomSpecifier<(...)>;
                                            required: false;
                                            values: ShapeDefinition<(...), (...)>;
                                        },
                                    ],
                                >,
                                false,
                            >;
                            searchParamsShape: { gameId: ShapeTuple<[string]> };
                        };
                    },
                    {
                        "/connect": {
                            messageFromClientShape: ShapeOr<
                                [
                                    ShapeDefinition<ShapeAnd<[(...), (...), (...)]>, false>,
                                    ShapeDefinition<ShapeAnd<[(...), (...), (...)]>, false>,
                                    ShapeDefinition<ShapeAnd<[(...), (...), (...)]>, false>,
                                ],
                            >;
                            messageFromHostShape: ShapeOr<
                                [
                                    ShapeDefinition<ShapeAnd<[(...), (...), (...)]>, false>,
                                    ShapeDefinition<ShapeAnd<[(...), (...), (...)]>, false>,
                                    ShapeDefinition<ShapeAnd<[(...), (...)]>, false>,
                                    ShapeDefinition<ShapeAnd<[(...), (...)]>, false>,
                                ],
                            >;
                            searchParamsShape: { gameId: ShapeTuple<[string]> };
                        };
                    },
                >,
            >,
        >

    The current MultiplayerApi. This will be undefined if playing in single player.

    multiplayerParams: undefined | Readonly<MultiplayerParams>

    This is populated if .startMultiplayer is called.

    rejectedRoomIds: Set<`${string}-${string}-${string}-${string}-${string}`> = ...

    Rooms that have rejected the current player, so the player doesn't keep trying to connect to them.

    roomConnectionState: Error | MultiplayerConnectionState = MultiplayerConnectionState.Disconnected

    The current connection state of the controller's connection to a multiplayer room.

    roomId: undefined | `${string}-${string}-${string}-${string}-${string}`

    Currently joined room id. If a room has not been joined yet, this will be empty.

    roomUpdateIntervalId: undefined | Timeout

    Used to keep track of the room update interval. This will be set when the controller is constructed in multiplayer mode or when a room is left. This will be cleared when a room is joined or if the controller is destroyed.

    serviceConnectionState: Error | MultiplayerConnectionState = MultiplayerConnectionState.Disconnected

    The current connection state of the controller's connection to a backend service.

    events: {
        ControllerClientEvent: typeof ControllerClientEvent;
        ControllerConnectionEvent: typeof ControllerConnectionEvent;
        ControllerFrameEvent: typeof ControllerFrameEvent;
        ControllerRoomListEvent: typeof ControllerRoomListEvent;
    } = ...

    All events emitted by this controller.

    knownErrors: { RoomRejectionError: typeof RoomRejectionError } = ...

    Methods