Created
January 3, 2015 14:24
-
-
Save confact/3168d2e3ec36aedcf68d to your computer and use it in GitHub Desktop.
station.js
This file contains 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 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