Skip to content

Instantly share code, notes, and snippets.

@tkurki
Created October 20, 2015 17:41
Show Gist options
  • Save tkurki/43d2d2f526066517fb3d to your computer and use it in GitHub Desktop.
Save tkurki/43d2d2f526066517fb3d to your computer and use it in GitHub Desktop.
var WebSocket = require('ws')
var url = "ws://" + "localhost:3000" + "/signalk/stream/v1?stream=delta";
var count = 0;
var connection = new WebSocket(url);
connection.onopen = function(msg) {
console.log("open")
var sub = '{"context":"vessels.self","subscribe":[{"path":"*"}]}';
connection.send(sub);
};
connection.onerror = function(error) {
console.log(error)
};
connection.onmessage = function(msg) {
count++;
};
setInterval(function() {
console.log(count);
count = 0;
}, 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment