Created
April 17, 2013 21:40
-
-
Save adrianmilne/5408013 to your computer and use it in GitHub Desktop.
CometD consumer javascript
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
google.load("jquery", "1"); | |
/** | |
* Callback function - Cometd consumer. | |
*/ | |
google.setOnLoadCallback(function() { | |
$.getScript("http://jquerycomet.googlecode.com/svn/trunk/jquery.comet.js", function(){ | |
console.log("done loading js"); | |
$.comet.init("http://localhost:9099/cometd"); | |
$.comet.subscribe("/broadcastMessageChannel", broadcastListener); | |
}); | |
}); | |
/** | |
* Listener function called on receipt of broadcast message. | |
*/ | |
function broadcastListener(msg) { | |
console.log("received broadcast: " + msg + ", " + msg.data); | |
$('<li>').html(msg.data).prependTo('#contentList').animate({color: "#000000"}, 6000); | |
$('html, body').animate({ scrollTop: 0 }, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment