uncategorized haxballClient - wxyz-abcd/node-haxball GitHub Wiki

HaxballClient

The keys for this object can be grouped in three categories:

1. Properties

  • storage: Storage: An object that stores information about the current player preferences. (documentation)

  • noPluginMechanism: boolean: If true, renderer and plugin mechanism will not work. Should only be used for optimal performance. You have to define Room._onXXXXXX callbacks by yourself.

  • config: RoomConfig | null: The RoomConfig object that contains all the main callbacks of this room. Default value is null. Note that the api will generate an empty config if you do not provide one. Look at examples/roomConfigs/method2 folder for example RoomConfigs to use here, or src/roomConfigTemplate_method2.js for a template RoomConfig that contains all callbacks. (documentation)

  • renderer: Renderer | null: The Renderer object that will render the game. The object should be derived from the provided Renderer class. Default value is null. Look at examples/renderers folder for example Renderers to use here, or src/rendererTemplate.js for a template Renderer that contains all callbacks. (documentation)

  • plugins: Plugin[]: An array of Plugin objects to be used. the objects should be derived from the provided Plugin class. Default value is []. Look at examples/plugins folder for example Plugins to use here, or src/pluginTemplate.js for a template Plugin that contains all callbacks. (documentation)

  • libraries: Library[]: An array of Library objects to be used. The objects should be derived from the provided Library class. Default value is []. Look at examples/libraries folder for example Library's to use here, or src/libraryTemplate.js for a template Library that contains all callbacks. (documentation)

  • version: int: Haxball's version number. Other clients cannot join this room if their version number is different than this number. Default value is 9.

  • kickTimeout: int: When we kick the ball, it causes us to release kick button by default. This API changes it so that it causes a timeout that makes us automatically press kick button again. We may assign a negative value to disable this feature. Default value is -1.

  • proxyAgent: Any http(s)/socks5 proxy agent that may be applied to the websocket connections. Does not work in browsers. Default value is null.

  • room: Room: Do not modify this value. This value is null until joinRoom or createRoom operation is successful. After that, a pointer to the created/joined room object is auto-assigned to this variable. (documentation)

2. Callbacks

  • onSuccess(room: Room): void

    Called when joining or creating a room was successful.

    Parameters:

    • room: Room: The room that succeeded in being created/joined. (documentation)

    Return value: void.

  • onFailure(error: HBError): void

    Called when Joining a room failed.

    Parameters:

    • error: HBError: The error that caused the failure. (documentation)

    Return value: void.

  • onLeave(msg: HBError): void

    Triggered while leaving the room.

    Parameters:

    Return value: void.

  • onConnectionStateChange(state: ConnectionState, sdp: string|undefined): void

    Triggered when the connection's state changed.

    Parameters:

    • state: ConnectionState: The new connection state. (documentation)
    • sdp: string|undefined: The session description value for webrtc connection. (only exists if state is ConnectingToPeer or AwaitingState.)

    Return value: void.

  • onReverseConnection(): void

    Triggered while starting to try the reverse connection method while joining a room.

    Parameters: None.

    Return value: void.

  • onRequestRecaptcha(): void

    Triggered when recaptcha is requested from the backend server while joining or creating a room.

    Parameters: None.

    Return value: void.

3. Event Triggers

  • cancel(): void

    This function cancels the process of joining a room. Does nothing if not currently trying to join a room.

    Parameters: None.

    Return value: void.

  • useRecaptchaToken(token: string): void

    Should be used to send the recaptcha token after onRequestRecaptcha callback is called. Currently only working while creating a room. Workaround: In order to send the token to try and join a recaptcha-protected room, clean up old resources and use Room.join with the new token.

    Parameters:

    • token: string: The recaptcha token.

    Return value: void.

⚠️ **GitHub.com Fallback** ⚠️