new Haxroomie( [ options ] )

Description

Class for spawning the headless chrome browser and managing RoomControllers.

Each RoomController controls one room running in a browsers tab.

After creating the Haxroomie instance it is required to launch the browser with the launchBrowser method before anything else.

Parameters
Name Type Attributes Description
options object <optional>

options

Name Type Attributes Default Description
viewport object <optional>
{ width: 400, height: 500 }

Viewport size settings for the browser.

port number <optional>
3066

Port that the headless browser will use as the remote-debugging-port to communicate with Haxroomie. Use a port that is not open outside your LAN!

noSandbox boolean <optional>
false

Makes the browser run without sandbox. Useful only if it gives you error in sandboxed mode. It is not recommended to set this true for security reasons.

headless boolean <optional>
true

Setting this to false will make puppeteer try to spawn a browser window. Useful for debugging.

userDataDir boolean <optional>

Path to where browser should store data like localStorage. Defaults to [project root directory]/user-data-dir.

timeout boolean <optional>
30

How long to wait for a room to open before failing.

executablePath string <optional>

Path to chrome launcher.

downloadDirectory string <optional>

Directory to where the files downloaded from the browser are saved.

chromiumArgs array <optional>

Additional arguments for the chromium browser.

Details

Methods


<async> launchBrowser()

Description

Launches the puppeteer controlled browser using the remote-debugging-port given in Haxroomie classes constructor. It is only possible to launch one browser.

Details

<async> closeBrowser()

Description

Closes the puppeteer controlled browser.

Details

hasRoom( id ) → {boolean}

Description

Checks if there is a room running with the given id.

Parameters
Name Type Description
id string | number

An id of the room.

Returns
  • Is there a room with given id?
Details

getRoom( id ) → {RoomController}

Description

Returns a RoomController with the given id.

Parameters
Name Type Description
id string | number

An id of the room.

Returns
  • RoomController with the given id or undefined if there is no such room.
Details

getRooms() → {Array.<RoomController>}

Description

Returns an array of available RoomControllers.

Returns
  • Available RoomControllers.
Details

getFirstRoom() → {RoomController}

Description

Returns the RoomController that was first added.

Returns
  • First RoomController or undefined if there is no such room.
Details

<async> removeRoom( id )

Description

Removes a RoomController with the given id.

Removing deletes the RoomController and closes the browser tab it is controlling.

Parameters
Name Type Description
id string | number
Details

<async> addRoom( roomController [, roomControllerOptions ] ) → {RoomController}

Description

Adds a new RoomController.

If roomController is a string or number, then it will be used as an id for the new RoomController.

Parameters
Name Type Attributes Description
roomController RoomController | string | number

Instance of RoomController or id for the RoomController.

roomControllerOptions object <optional>

Additional options for the RoomController constructor if roomController is an id.

Returns
  • The created RoomController.
Details

Events


room-added

Description

Emitted when new RoomController is added.

Parameters
Name Type Description
room RoomController

The added RoomController.

Details

room-removed

Description

Emitted when RoomController is removed.

Parameters
Name Type Description
room RoomController

The removed RoomController.

Details