Skip to content

HoloPlayCore.Client

A class representing a client that communicates with HoloPlay Service.

Constructor

  • initCallback function optional; a function that triggers when response is received.
  • errCallback function optional; a function that triggers when there is a connection error.
  • closeCallback function optional; a function that triggers when the socket is closed.
  • debug boolean optional; default is false. If true, there will be logging messages in console.
  • appId string optional; see InitMessage for more details.
  • isGreedy boolean optional; see InitMessage for more details.
  • oncloseBehavior string optional; see InitMessage for more details.

Returns information of the connected Looking Glass devices, in the format of device status response.

Example

const client = new HoloPlayCore.Client(
  (msg) => {
    console.log('Calibration values:', msg);
  },
  (err) => {
    console.error('Error creating HoloPlay client:', err);
  });

Methods

.sendMessage(msg, timeoutSecs)

Send a Message object over the websocket to the HoloPlay Service.

  • msg Message object
  • timeoutSecs integer optional, default is 60 seconds

Returns a Promise.

Example

let infoMsg = new HoloPlayCore.InfoMessage();
client.sendMessage(infoMsg)
  .then(() => console.log('Response received'))
  .catch((err) => console.log(err));

.disconnect()

Manually disconnects from the web socket.

Example

client.disconnect();