2009-04-26 03:20:24 +09:00
|
|
|
// update the local timeline from a Comet server
|
|
|
|
//
|
|
|
|
|
2009-04-27 01:06:50 +09:00
|
|
|
var updater = function()
|
|
|
|
{
|
2009-04-27 04:08:49 +09:00
|
|
|
var _cometd;
|
2009-04-27 01:06:50 +09:00
|
|
|
|
2009-04-27 04:08:49 +09:00
|
|
|
return {
|
|
|
|
init: function(server, timeline)
|
|
|
|
{
|
|
|
|
_cometd = $.cometd; // Uses the default Comet object
|
|
|
|
_cometd.setLogLevel('debug');
|
|
|
|
_cometd.init(server);
|
|
|
|
_cometd.subscribe(timeline, receive);
|
|
|
|
$(window).unload(leave);
|
|
|
|
}
|
|
|
|
}
|
2009-04-27 01:06:50 +09:00
|
|
|
|
2009-04-27 04:08:49 +09:00
|
|
|
function leave()
|
|
|
|
{
|
|
|
|
_cometd.disconnect();
|
|
|
|
}
|
2009-04-27 01:06:50 +09:00
|
|
|
|
2009-04-27 04:08:49 +09:00
|
|
|
function receive(message)
|
|
|
|
{
|
|
|
|
alert("Received notice.");
|
|
|
|
var noticeItem = makeNoticeItem(message.data);
|
|
|
|
var noticeList = $('ul.notices');
|
|
|
|
}
|
|
|
|
|
|
|
|
function makeNoticeItem(data)
|
|
|
|
{
|
|
|
|
return '';
|
|
|
|
}
|
2009-04-27 01:06:50 +09:00
|
|
|
}();
|
2009-04-27 04:08:49 +09:00
|
|
|
|