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

CommonNetworkRoomParams

The keys for this object can be grouped in two 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.

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

  • identityToken: A token that represents a user data in a database of a custom proxy/backend server. Defaults to null.

2. Callbacks

  • preInit(room: Room): void

    Called just after the room object is created, and before the initialization of the addons. This is where you can initialize/add your custom GUI functions to the room object to be used inside the addons.

    Parameters:

    • room: Room: The room object that was just created. (documentation)

    Return value: void.

  • onOpen(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.

  • onClose(error: HBError): void

    Called when joining/creating a room failed, room.leave() was called, or the room was closed.

    Parameters:

    • error: HBError: The error that caused the failure. Will be null if room.leave() was called. (documentation)

    Return value: void.

  • onConnInfo(state: ConnectionState, extraInfo: string|undefined): void

    Triggered when the connection's state changed, or started trying the reverse connection method while joining a room.

    Parameters:

    • state: ConnectionState: The new connection state. (documentation)
    • extraInfo: string|HBError|undefined: Extra information depending on the connection state:
      • if state is ConnectingToPeer or AwaitingState: The session description value for webrtc connection.
      • if state is ConnectionFailed: The error object that may contain information about why the connection failed.
      • otherwise: undefined.

    Return value: void.

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