summaryrefslogtreecommitdiff
path: root/plugins/Comet/cometupdate.js
blob: 72cca004b7b5f8195fc165aff261e0b08c2104b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// update the local timeline from a Comet server
//

var CometUpdate = function()
{
     var _server;
     var _timeline;
     var _userid;
     var _replyurl;
     var _favorurl;
     var _deleteurl;
     var _cometd;

     return {
          init: function(server, timeline, userid, replyurl, favorurl, deleteurl)
          {
               _cometd = $.cometd; // Uses the default Comet object
               _cometd.init(server);
               _server = server;
               _timeline = timeline;
               _userid = userid;
               _favorurl = favorurl;
               _replyurl = replyurl;
               _deleteurl = deleteurl;
               _cometd.subscribe(timeline, function(message) { RealtimeUpdate.receive(message.data) });
               $(window).unload(function() { _cometd.disconnect(); } );
          }
     }
}();