# 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.&#x20;
* `appId` **string** optional; see [InitMessage](https://lfdocs.lookingglassfactory.com/legacy/legacy-software/corejs/message#initmessage) for more details.&#x20;
* `isGreedy` **boolean** optional; see [InitMessage](https://lfdocs.lookingglassfactory.com/legacy/legacy-software/corejs/message#initmessage) for more details.&#x20;
* `oncloseBehavior` **string** optional; see [InitMessage](https://lfdocs.lookingglassfactory.com/legacy/legacy-software/corejs/message#initmessage) for more details.&#x20;

Returns information of the connected Looking Glass devices, in the format of [device status response](https://lfdocs.lookingglassfactory.com/legacy/legacy-software/corejs/hops-related#device-status).

**Example**

```javascript
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](https://lfdocs.lookingglassfactory.com/legacy/legacy-software/corejs/api/message) object over the websocket to the HoloPlay Service.

* `msg` [**Message**](https://lfdocs.lookingglassfactory.com/legacy/legacy-software/corejs/api/message) object
* `timeoutSecs` **integer** optional, default is `60` seconds

Returns a Promise.

**Example**

```javascript
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**

```javascript
client.disconnect();
```
