Skip to content

Instantly share code, notes, and snippets.

@ProbablePrime
Created March 4, 2016 21:23
Show Gist options
  • Save ProbablePrime/65ec4eacfe159fcfa6cf to your computer and use it in GitHub Desktop.
Save ProbablePrime/65ec4eacfe159fcfa6cf to your computer and use it in GitHub Desktop.
var Client = require('wsabi-client-bacon');
var client = new Client("wss://realtime.beam.pro");
client.socket.on("open", function () {
console.log("Socket connection open!");
// Send requests to the server with get, put, post, delete, or request.
client.get("/api/v1/channels/Youplay").then(function(res) {
// Subscribe to a live event
client.live('channel:'+res.id+':update').then(function(res) {
res.onValue(function(value){
console.log(value.viewersCurrent);
});
});
}, function(res){
console.log(arguments);
console.log(res);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment