Created
July 15, 2019 18:42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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