Members
-
running :boolean
-
Description
Is the room running.
Details
-
hhmLoaded :boolean
-
Description
Is Haxball Headless Manager loaded.
Details
-
usable :boolean
-
Description
Is the instance still usable.
Details
-
roomInfo :object
-
Description
If room is running, contains its data (like e.g.
roomInfo.roomLink). If not running, then this isnull. Returns a copy of the original object.Details
-
openRoomLock :boolean
-
Description
If opening of the room is in process, then this will be
true.Details
-
plugins :PluginController
-
Description
Object that can be used to control and get information about plugins.
Requires the room to be running!
Details
-
repositories :RepositoryController
-
Description
Object that can be used to control and get information about repositories.
Requires the HHM library to be loaded!
To load HHM you can use the init() method or open the room with openRoom().
Details
-
roles :RoleController
-
Description
Object that can be used to control and get information about roles.
Requires the room to be running and sav/roles plugin to be loaded and enabled!
Details
Methods
-
<async> init( [ options ] )
-
Description
Initializes the RoomController by navigating the page to the headless HaxBall URL and loads the Haxball Headless Manager library.
This enables the use of the repositories object to get information about repositories before opening the room.
Note that calling close will undo this.
Parameters
Name Type Attributes Description optionsobject <optional> Options.
Name Type Attributes Description hhmVersionstring <optional> Version of Haxball Headless Manager to load. By default a compatible version is used.
hhmFile <optional> Optionally load HHM source from a string.
Details
-
<async> openRoom( config ) → {object}
-
Description
Opens a HaxBall room in a browser tab.
On top of the documentated properties here, the config object can contain any properties you want to use in your own HHM config file.
The config object is usable globally from within the HHM config as the
hrConfigobject.Parameters
Name Type Description configobject Config object that contains the room information.
Name Type Attributes Description tokenstring Token to start the room with. Obtain one from https://www.haxball.com/headlesstoken.
roomNamestring <optional> Room name.
playerNamestring <optional> Host player name.
maxPlayersint <optional> Max players.
publicboolean <optional> Should the room be public?
geoobject <optional> Geolocation override for the room.
repositoriesArray.<Repository> <optional> Array of HHM plugin repositories.
e.g. To load a repository from GitHub:
repositories: [ { type: 'github', repository: 'morko/hhm-sala-plugins', path: 'src', // optional (defaults to src) version: 'master', // optional (defaults to master) suffix: '.js', // optional (defaults to .js) } ],See Repository for the types of repositories you can use.
pluginConfigobject <optional> Haxball Headless Manager plugin config object. Passed to
HHM.config.plugins.See Haxball Headless Manager This tells HHM which plugins to load from the available repositories. You can also give the initial config to plugins here.
roomScriptFile <optional> Regular haxball headless script to load when starting the room.
Disables the non essential default plugins.
hhmConfigFile <optional> Configuration for the haxball headless manager (HHM).
defaultRepoVersionstring <optional> Version of saviola's plugin repository for Haxball Headless Manager to load. By default a compatible version is used. This can be overriden by adding the repository in the
repositoryproperty.Returns
Fires
Throws
Details
-
<async> closeRoom()
-
Description
Closes the headless HaxBall room by navigating the page out of the headless HaxBall URL.
Fires
Throws
Details
-
<async> callRoom( fn ) → {Promise.<any>}
-
Description
Calls a function of the HaxBall roomObject in the browsers context.
Parameters
Name Type Description fnstring Name of the haxball roomObject function.
..argsany Arguments for the function.
Returns
Throws
Details
-
<async> eval( pageFunction [, ...args ] ) → {Promise.<Serializable>}
-
Description
Wrapper for Puppeteers page.evaluate.
Evaluates the given code in the browser tab this instace is controlling. You can access the HaxBall roomObject with
HHM.manager.room.e.g.
room.eval('HHM.manager.room.getPlayerList()');Parameters
Name Type Attributes Description pageFunctionstring | function JavaScript to evaluate.
argsSerializable | JSHandle <optional>
<repeatable>Arguments to pass to
js.Returns
Details
Events
-
page-closed
-
Description
Emitted when the browser tab gets closed. Renders this RoomController unusable.
Parameters
Name Type Description roomRoomController Instance of RoomController that was controlling the page.
Details
-
page-crash
-
Description
Emitted when the browser tab crashes. Renders this RoomController unusable.
Parameters
Name Type Description errorError The error that was thrown.
Details
-
page-error
-
Description
Emitted when some script throws an error in the browsers tab.
Parameters
Name Type Description errorError The error that was thrown.
Details
-
error-logged
-
Description
Emitted when a browser tab logs an error to the console.
Parameters
Name Type Description messagestring The logged error message.
Details
-
warning-logged
-
Description
Emitted when a browser tab logs a warning to the console.
Parameters
Name Type Description messagestring The logged warning message.
Details
-
info-logged
-
Description
Emitted when a browser tab logs to console.
Parameters
Name Type Description messagestring The logged message.
Details
-
open-room-start
-
Description
Emitted when RoomController#openRoom has been called.
Parameters
Name Type Attributes Description errorError | UnusableError | RoomIsRunningError | RoomLockedError <optional> If error happened when starting to open room.
configobject Config object given as argument to RoomController#openRoom
Details
-
open-room-stop
-
Description
Emitted when RoomController#openRoom has finished and the room is running. e.g.
room.on('open-room-stop', (err, roomInfo)=> { if (err) { console.log('Room did not open.', err); } else { console.log('Room was opened', roomInfo); } }); room.openRoom(config);Parameters
Name Type Attributes Description errorError | ConnectionError | TimeoutError | InvalidTokenError <optional> - If error happened when opening the room.
roomInfoobject Information about the room.
Details
-
close-room-start
-
Description
Emitted when RoomController#closeRoom has been called.
Parameters
Name Type Attributes Description errorUnusableError <optional> If the room is at unusable state.
Details
-
close-room-stop
-
Description
Emitted when RoomController#closeRoom has finished.
Parameters
Name Type Attributes Description errorError <optional> If error happened during closeRoom.
Details
-
room-event
-
Description
Emitted when supported HaxBall roomObject event happens.
Parameters
Name Type Description roomEventArgsRoomEventArgs Event arguments.
Details
-
plugin-loaded
-
Description
Emitted when a plugin is loaded.
Parameters
Name Type Description pluginDataPluginData Information about the plugin.
Details
-
plugin-removed
-
Description
Emitted when a plugin is removed.
Parameters
Name Type Description pluginDataPluginData Information about the plugin.
Details
-
plugin-enabled
-
Description
Emitted when a plugin is enabled.
Parameters
Name Type Description pluginDataPluginData Information about the plugin.
Details
-
plugin-disabled
-
Description
Emitted when a plugin is disabled.
Parameters
Name Type Description pluginDataPluginData Information about the plugin.
Details