Skip to content

Instantly share code, notes, and snippets.

@AdamMagaluk
Created March 5, 2014 20:30
Show Gist options
  • Save AdamMagaluk/9375946 to your computer and use it in GitHub Desktop.
Save AdamMagaluk/9375946 to your computer and use it in GitHub Desktop.
Websocket pub/sub client.
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