mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
Check if push server is available otherwise fallback into polling
This commit is contained in:
parent
ea548a90ab
commit
d9ff68a422
@ -87,6 +87,12 @@ class notifications_ajax {
|
|||||||
*/
|
*/
|
||||||
private $response;
|
private $response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var type
|
||||||
|
*/
|
||||||
|
private $isPushServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor
|
* constructor
|
||||||
*
|
*
|
||||||
@ -101,6 +107,13 @@ class notifications_ajax {
|
|||||||
$this->preferences = $prefs->read();
|
$this->preferences = $prefs->read();
|
||||||
|
|
||||||
$this->db = $GLOBALS['egw']->db;
|
$this->db = $GLOBALS['egw']->db;
|
||||||
|
|
||||||
|
if (empty(($isPushServer = Api\Cache::getCache(Api\Cache::INSTANCE, 'notifications', 'isPushServer'))))
|
||||||
|
{
|
||||||
|
$isPushServer = (!((New Api\Json\Push ()) instanceof notifications_push));
|
||||||
|
Api\Cache::setCache(Api\Cache::INSTANCE, 'notifications','isPushServer', $isPushServer, 86400);
|
||||||
|
}
|
||||||
|
$this->isPushServer = $isPushServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,7 +139,7 @@ class notifications_ajax {
|
|||||||
{
|
{
|
||||||
$this->response->jquery('#currentusers', 'text', array((string)$GLOBALS['egw']->session->session_count()));
|
$this->response->jquery('#currentusers', 'text', array((string)$GLOBALS['egw']->session->session_count()));
|
||||||
}
|
}
|
||||||
|
if ($this->isPushServer) $this->response->data(['isPushServer' => true]);
|
||||||
$this->get_egwpopup($browserNotify);
|
$this->get_egwpopup($browserNotify);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,8 +95,9 @@
|
|||||||
notifications.prototype.run_notifications = function ()
|
notifications.prototype.run_notifications = function ()
|
||||||
{
|
{
|
||||||
var self = this;
|
var self = this;
|
||||||
this.get_notifications().then(function(){
|
this.get_notifications().then(function(_data){
|
||||||
window.clearTimeout(TIMEOUT);
|
window.clearTimeout(TIMEOUT);
|
||||||
|
if (_data && _data.isPushServer) return;
|
||||||
self.check_browser_notify();
|
self.check_browser_notify();
|
||||||
TIMEOUT = self.setTimeout(POLL_INTERVAL);
|
TIMEOUT = self.setTimeout(POLL_INTERVAL);
|
||||||
},
|
},
|
||||||
@ -116,8 +117,8 @@
|
|||||||
return new Promise (function(_resolve, _reject){
|
return new Promise (function(_resolve, _reject){
|
||||||
egw.json(
|
egw.json(
|
||||||
"notifications.notifications_ajax.get_notifications",[],
|
"notifications.notifications_ajax.get_notifications",[],
|
||||||
function(){
|
function(_data){
|
||||||
_resolve();
|
_resolve(_data);
|
||||||
self.check_browser_notify()
|
self.check_browser_notify()
|
||||||
}).sendRequest(true,'POST', function(_err){
|
}).sendRequest(true,'POST', function(_err){
|
||||||
if (_err && _err.statusText) egw.message(_err.statusText);
|
if (_err && _err.statusText) egw.message(_err.statusText);
|
||||||
|
Loading…
Reference in New Issue
Block a user