cometupdate.js 845 B

12345678910111213141516171819202122232425262728
  1. // update the local timeline from a Comet server
  2. var CometUpdate = function()
  3. {
  4. var _server;
  5. var _timeline;
  6. var _userid;
  7. var _replyurl;
  8. var _favorurl;
  9. var _deleteurl;
  10. var _cometd;
  11. return {
  12. init: function(server, timeline, userid, replyurl, favorurl, deleteurl)
  13. {
  14. _cometd = $.cometd; // Uses the default Comet object
  15. _cometd.init(server);
  16. _server = server;
  17. _timeline = timeline;
  18. _userid = userid;
  19. _favorurl = favorurl;
  20. _replyurl = replyurl;
  21. _deleteurl = deleteurl;
  22. _cometd.subscribe(timeline, function(message) { RealtimeUpdate.receive(message.data) });
  23. $(window).unload(function() { _cometd.disconnect(); } );
  24. }
  25. }
  26. }();