Skip to content

Instantly share code, notes, and snippets.

@voipnorm
Created July 15, 2019 18:42
const WebSocket = require('ws');
const XAPI = require('jsxapi/lib/xapi').default;
const WSBackend = require('jsxapi/lib/backend/ws').default;
const url = 'ws://codecip/ws';
const username = 'admin';
const password = '';
const auth = Buffer.from(`${username}:${password}`).toString('base64');
const options = {
headers: {
'Authorization': `Basic ${auth}`,
}
};
const websocket = new WebSocket(url, options);
websocket.on('error', console.error);
const xapi = new XAPI(new WSBackend(websocket));
xapi.status.get('Audio Volume')
.then(console.log)
.catch(console.error);
xapi.status.on('Audio Volume', console.log);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment