diff --git a/src/webui/comet.c b/src/webui/comet.c index b03f2f72..6280c051 100644 --- a/src/webui/comet.c +++ b/src/webui/comet.c @@ -158,11 +158,14 @@ comet_mailbox_poll(http_connection_t *hc, const char *remain, void *opaque) { comet_mailbox_t *cmb = NULL; const char *cometid = http_arg_get(&hc->hc_req_args, "boxid"); + const char *immediate = http_arg_get(&hc->hc_req_args, "immediate"); + int im = immediate ? atoi(immediate) : 0; time_t reqtime; struct timespec ts; htsmsg_t *m; - usleep(100000); /* Always sleep 0.1 sec to avoid comet storms */ + if(!im) + usleep(100000); /* Always sleep 0.1 sec to avoid comet storms */ pthread_mutex_lock(&comet_mutex); @@ -182,7 +185,7 @@ comet_mailbox_poll(http_connection_t *hc, const char *remain, void *opaque) cmb->cmb_last_used = 0; /* Make sure we're not flushed out */ - if(cmb->cmb_messages == NULL) + if(!im && cmb->cmb_messages == NULL) pthread_cond_timedwait(&comet_cond, &comet_mutex, &ts); m = htsmsg_create_map(); diff --git a/src/webui/static/app/comet.js b/src/webui/static/app/comet.js index 1e3dc8d5..33bb1685 100644 --- a/src/webui/static/app/comet.js +++ b/src/webui/static/app/comet.js @@ -29,19 +29,22 @@ tvheadend.cometPoller = function() { Ext.Ajax.request({ url: 'comet', - params : boxid ? { boxid: boxid } : null, + params : { + boxid: (boxid ? boxid : null), + immediate: failures > 0 ? 1 : 0 + }, success: function(result, request) { parse_comet_response(result.responseText); - if(failures > 2) { + if(failures > 1) { tvheadend.log('Reconnected to Tvheadend', 'font-weight: bold; color: #080'); } failures = 0; }, failure: function(result, request) { - cometRequest.delay(failures > 10 ? 5000 : failures * 500); - if(failures > 2) { + cometRequest.delay(failures ? 1000 : 1); + if(failures == 1) { tvheadend.log('There seems to be a problem with the ' + 'live update feed from Tvheadend. ' + 'Trying to reconnect...',