mooball
    Preparing search index...

    Type Alias Room

    type Room = {
        create(
            createParams: CreateRoomParams,
            commonParams: CommonNetworkRoomParams,
        ): CommonNetworkRoomReturnType;
        join(
            joinParams: JoinRoomParams,
            commonParams: CommonNetworkRoomParams,
        ): CommonNetworkRoomReturnType;
        sandbox(
            callbacks: CommonlyUsedCallbacks & CustomCallbacks & SandboxOnlyCallbacks,
            options: SandboxOptions,
        ): SandboxRoom;
        streamWatcher(
            initialStreamData: Uint8Array,
            callbacks: CommonlyUsedCallbacks & CustomCallbacks,
            options: SandboxOptions,
        ): StreamWatcherRoom;
    }
    Index

    Methods

    • Creates a room with given parameters.

      Parameters

      • createParams: CreateRoomParams

        An object that might have the following keys:

        • name: string: Name of the room.
        • password: string | null: A password string to protect the room, or null for no password.
        • token: string: In order to create a room, we have to solve a recaptcha challenge and write the resulting token into this key. The recaptcha token can be originally obtained from https://moo-hoo.com/mooball/headlesstoken. However, this url will be different while using a custom backend server.
        • noPlayer: boolean: Determines whether a player object will be created for the room host or not.
        • geo: GeoLocation: The geolocation value of the room about to be created.
        • playerCount: int | null: If set to an int, fixes the current player count to this specific value.
        • maxPlayerCount: int: The maximum allowed player count in the room.
        • unlimitedPlayerCount: boolean: If set to true, bypasses the player count checks, resulting in unlimited maximum player count. However, the default backend will not show the room in the room list if the player count > 30.
        • fakePassword: boolean | null: If set to true or false, the room will set its password-protected status to your value. Passing null disables this behaviour.
        • showInRoomList: boolean: Whether to show this room in the room list or not.
        • tintColor: int: Background tint color(to show in room list) of the room.
        • thumbnail: string|null: Thumbnail(to show in room list) of the room.
        • endpoint: string|null: Endpoint of the room.
        • hideIdentity: boolean: Whether to hide the owner of the room or not.
        • onError: Function(error: HBError, playerId: int): Called when a exception is thrown by one of the client connections. playerId is the id of the player that caused the exception. The player's connection will be closed just after this callback is executed.
      • commonParams: CommonNetworkRoomParams

        An object that might have the following keys:

        • storage: An object that stores information about the current player preferences. It may consist of these keys:
          • crappy_router: if true, sets some timeout value to 10 seconds instead of 4 seconds while joining a room.
          • player_name: name of the player. default value is "abc".
          • avatar: avatar of the player. default value is null.
          • geo: geolocation of the player. it may consist of these keys:
            • lat: latitude value (number, default value is 40).
            • lon: longitude value (number, default value is 40).
            • flag: 2 letter country code (string, default value is "tr").
        • noPluginMechanism: whether the plugin mechanism will be passive or not. (default value is false)
        • config: A RoomConfig object. (default value is null)
        • renderer: A Renderer object. (default value is null)
        • plugins: An array of Plugins to activate. (default value is [])
        • libraries: An array of Librarys to activate. (default value is [])
        • version: The version of this room. (default value is 9)
        • proxyAgent: A custom proxy agent to use for the room's connection. (default value is null)
        • identityToken: A token that represents a user data in a database of a custom proxy/backend server. (default value is null)
        • debugDesync: A callback in client rooms that will be called whenever a desync occurs if the host room also has a true value for this key. Look at https://github.com/wxyz-abcd/mooball/tree/main/examples/other/compareStates.js for the default implementation of desync checking. (default value is null)
        • preInit(room: Room)=>void: A callback that is called just after the room is created, and before the initialization of the addons.. (default value is null)
        • onOpen(room: Room)=>void: A callback that is called when joining or creating a room was successful. (default value is null)
        • onClose(reason: HBError)=>void: A callback that is called while leaving the room. (default value is null)
        • onConnInfo(state: ConnectionState, extraInfo?: string|HBError)=>void: A callback that is called whenever the connection's state changed while joining a room. (default value is null)

      Returns CommonNetworkRoomReturnType

      An object that has the following triggers:

      • cancel(): This function can be called to cancel the process of creating a room, or also to close the room later.
      • useRecaptchaToken(token): This function can be called to try the process of creating a room again whenever the recaptcha token was rejected.
    • Tries to join a room using the given parameters.

      Parameters

      • joinParams: JoinRoomParams

        An object that might have the following keys:

        • id: string: The id of the room to join. For example, if the room link is https://moo-hoo.com/mooball/join?c=ZzZzZzZzZzZzZzZzZz, the id of this room is ZzZzZzZzZzZzZzZzZz.
        • password: string | null: A password value to join the room if the room is password-protected.
        • token: string | null: If the room is recaptcha-protected, you have to use a client token. Currently there is not any other clean way of generating this token for Mooball's original backend except using the NW.js token generator project, so you might want to look at it.
        • authObj: Auth: An auth object that has to be initialized by Utils.generateAuth() or Utils.authFromKey() before being used here.
      • commonParams: CommonNetworkRoomParams

        An object that might have the following keys:

        • storage: An object that stores information about the current player preferences. It may consist of these keys:
          • crappy_router: if true, sets some timeout value to 10 seconds instead of 4 seconds while joining a room.
          • player_name: name of the player. default value is "abc".
          • avatar: avatar of the player. default value is null.
          • geo: geolocation of the player. it may consist of these keys:
            • lat: latitude value (number, default value is 40).
            • lon: longitude value (number, default value is 40).
            • flag: 2 letter country code (string, default value is "tr").
        • noPluginMechanism: whether the plugin mechanism will be passive or not. (default value is false)
        • config: A RoomConfig object. (default value is null)
        • renderer: A Renderer object. (default value is null)
        • plugins: An array of Plugins to activate. (default value is [])
        • libraries: An array of Librarys to activate. (default value is [])
        • version: The version of this room. (default value is 9)
        • proxyAgent: A custom proxy agent to use for the room's connection. (default value is null)
        • identityToken: A token that represents a user data in a database of a custom proxy/backend server. (default value is null)
        • debugDesync: A callback in client rooms that will be called whenever a desync occurs if the host room also has a true value for this key. Look at https://github.com/wxyz-abcd/mooball/tree/main/examples/other/compareStates.js for the default implementation of desync checking. (default value is null)
        • preInit(room: Room)=>void: A callback that is called just after the room is created, and before the initialization of the addons.. (default value is null)
        • onOpen(room: Room)=>void: A callback that is called when joining or creating a room was successful. (default value is null)
        • onClose(reason: HBError)=>void: A callback that is called while leaving the room. (default value is null)
        • onConnInfo(state: ConnectionState, extraInfo?: string|HBError)=>void: A callback that is called whenever the connection's state changed while joining a room. (default value is null)

      Returns CommonNetworkRoomReturnType

      An object that has the following triggers:

      • cancel(): This function can be called to cancel the process of creating a room, or also to close the room later.
      • useRecaptchaToken(token): This function can be called to try the process of creating a room again whenever the recaptcha token was rejected.
    • Creates a sandbox room object.

      Parameters

      • callbacks: CommonlyUsedCallbacks & CustomCallbacks & SandboxOnlyCallbacks

        An object that may have all callbacks defined in sections 2, 3.1, 4 and 6 of our event callbacks documentation. In addition, it is possible to use a render callback that has the same signature as defined in section 3 of our Renderer documentation.

      • options: SandboxOptions

        An object that might have the following keys:

        • controlledPlayerId: int | null: Id of the player to be controlled.
        • delayedInit: boolean: Whether to delay the initialization of the sandbox. (You have to manually initialize it later using its initialize() function.)
        • requestAnimationFrame: ((callback: function, ...args: any[])=>number) | null: Override function for requestAnimationFrame. Omit to use library's default requestAnimationFrame.
        • cancelAnimationFrame: ((handle: number)=>void) | null: Override function for cancelAnimationFrame. Omit to use library's default cancelAnimationFrame.

      Returns SandboxRoom

      An instance of the SandboxRoom structure.

    • Creates a stream watcher room object.

      Parameters

      • initialStreamData: Uint8Array

        The initial Uint8Array data that is received just after connecting to a streaming room.

      • callbacks: CommonlyUsedCallbacks & CustomCallbacks

        An object that may have all callbacks defined in sections 2, 3.1, 4 and 6 of our event callbacks documentation. In addition, it is possible to use a render callback that has the same signature as defined in section 3 of our Renderer documentation.

      • options: SandboxOptions

        An object that might have the following keys:

        • requestAnimationFrame: ((callback: function, ...args: any[])=>number) | null: Override function for requestAnimationFrame. Omit to use library's default requestAnimationFrame.
        • cancelAnimationFrame: ((handle: number)=>void) | null: Override function for cancelAnimationFrame. Omit to use library's default cancelAnimationFrame.

      Returns StreamWatcherRoom

      An instance of the StreamWatcherRoom structure.