↳ Connectivity

AirConsole

new AirConsole(opts) → {AirConsoleObject}

Your gateway object to AirConsole. There are getter and setter functions for all properties. Do not access properties of this object directly.
Parameters:
Name Type Description
opts AirConsole~Config Constructor config, see bellow.
Source:
Returns:
The AirConsole object.
Type
AirConsoleObject

Methods

arePlayersSilenced() → {boolean}

Queries, if new devices are currently silenced.
Since:
  • 1.9.0
Source:
Returns:
True, if new devices that are not players are silenced.
Type
boolean

getControllerDeviceIds() → {Array}

Returns all controller device ids that have loaded your game.
Source:
Returns:
Type
Array

getDeviceId() → {number}

Returns the device_id of this device. Every device in an AirConsole session has a device_id. The screen always has device_id 0. You can use the AirConsole.SCREEN constant instead of 0. All controllers also get a device_id. You can NOT assume that the device_ids of controllers are consecutive or that they start at 1. DO NOT HARDCODE CONTROLLER DEVICE IDS! If you want to have a logic with "players numbers" (Player 0, Player 1, Player 2, Player 3) use the setActivePlayers helper function! You can hardcode player numbers, but not device_ids. Within an AirConsole session, devices keep the same device_id when they disconnect and reconnect. Different controllers will never get the same device_id in a session. Every device_id remains reserved for the device that originally got it.
Source:
See:
Returns:
Type
number

getMasterControllerDeviceId() → {number|undefined}

Returns the device ID of the master controller. Premium devices are prioritzed.
Source:
Returns:
Type
number | undefined

getServerTime() → {number}

Returns the current time of the game server. This allows you to have a synchronized clock: You can send the server time in a message to know exactly at what point something happened on a device. This function can only be called if the AirConsole was instantiated with the "synchronize_time" opts set to true and after onReady was called.
Source:
Returns:
Timestamp in milliseconds.
Type
number

(abstract) onConnect(device_id)

Gets called when a device has connected and loaded the game.
Parameters:
Name Type Description
device_id number the device ID that loaded the game.
Source:

(abstract) onDisconnect(device_id)

Gets called when a device has left the game.
Parameters:
Name Type Description
device_id number the device ID that left the game.
Source:

(abstract) onReady(code)

Gets called when the game console is ready. This event also fires onConnect for all devices that already are connected and have loaded your game. This event also fires onCustomDeviceStateChange for all devices that are connected, have loaded your game and have set a custom Device State.
Parameters:
Name Type Description
code string The AirConsole join code.
Source: