Created
March 5, 2014 20:30
-
-
Save AdamMagaluk/9375946 to your computer and use it in GitHub Desktop.
Websocket pub/sub client.
This file contains hidden or 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 ws = require('ws'); | |
var socket = new ws('ws://localhost:3000/events'); | |
socket.on('open',function(){ | |
socket.send( JSON.stringify({cmd : 'subscribe',name : 'photosensor/value'}) ); | |
}); | |
socket.on('message',function(data){ | |
console.log(data); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment