Created
September 24, 2015 17:18
-
-
Save sdhibit/f417fe24d5b1c93ce4e5 to your computer and use it in GitHub Desktop.
Node.js demo of ISY994 REST subscription using websockets
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
var WebSocket = require('ws'); | |
var username = 'admin'; //replace with admin username | |
var password = 'password'; //replace with admin password | |
var host = '192.168.1.100'; //replace with your ISY IP | |
var auth = username + ':' + password; | |
var url = 'ws://' + auth + '@' + host + '/rest/subscribe'; | |
var ws = new WebSocket(url, 'ISYSUB', { | |
origin: 'com.universal-devices.websockets.isy', | |
protocolVersion: 13 | |
}); | |
ws.on('open', function open() { | |
console.log('connected'); | |
}); | |
ws.on('close', function close() { | |
console.log('disconnected'); | |
}); | |
ws.on('message', function message(data, flags) { | |
console.log("*******************************"); | |
console.log(data); | |
console.log("*******************************"); | |
console.log(""); | |
}); | |
ws.on('error', function(error) { | |
console.log(error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run the following command in same directory as this file.