Skip to content

Instantly share code, notes, and snippets.

@confact
Created January 3, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save confact/3168d2e3ec36aedcf68d to your computer and use it in GitHub Desktop.
Save confact/3168d2e3ec36aedcf68d to your computer and use it in GitHub Desktop.
station.js
var dispatcher = new WebSocketRails('localhost/websocket');
dispatcher.on_open = function(data) {
console.log('connected!');
var stationid = $('#songhistorylist').data("id");
var stationname = 'station' + String(stationid);
var channel = dispatcher.subscribe(stationname);
channel.bind('new_song', function (song) {
console.log(song);
console.log('a new song about ' + song.name + " - " + song.title + ' arrived!');
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment