IDEMPIERE-175 Atmosphere server push. 1) Timeout shouldn't increase failure count. 2) Use oncomplete event to schedule the next long polling call and eliminate the duplicate code in onError and onSuccess. 3) Reduce the delay between complete and next long polling call from 250ms to 10ms. 4) stop should immediately set active to false.
This commit is contained in:
parent
f46d53670a
commit
5ee9dfc9b1
|
@ -15,7 +15,7 @@
|
|||
jawwa.atmosphere.ServerPush = zk.$extends(zk.Object, {
|
||||
desktop: null,
|
||||
active: false,
|
||||
delay: 250,
|
||||
delay: 10,
|
||||
failures: 0,
|
||||
timeout: 0,
|
||||
ajaxOptions: {
|
||||
|
@ -34,17 +34,20 @@
|
|||
this.ajaxOptions.timeout = this.timeout;
|
||||
var me = this;
|
||||
this.ajaxOptions.error = function(jqxhr, textStatus, errorThrown) {
|
||||
if (typeof console == "object") {
|
||||
console.error(textStatus);
|
||||
console.error(errorThrown);
|
||||
}
|
||||
me.failures += 1;
|
||||
me._schedule();
|
||||
if (textStatus != "timeout") {
|
||||
if (typeof console == "object") {
|
||||
console.error(textStatus);
|
||||
console.error(errorThrown);
|
||||
}
|
||||
me.failures += 1;
|
||||
}
|
||||
};
|
||||
this.ajaxOptions.success = function(data) {
|
||||
zAu.cmd0.echo(this.desktop);
|
||||
me.failures = 0;
|
||||
me._schedule();
|
||||
};
|
||||
this.ajaxOptions.complete = function() {
|
||||
me._schedule();
|
||||
};
|
||||
},
|
||||
_schedule: function() {
|
||||
|
@ -68,8 +71,8 @@
|
|||
this._send();
|
||||
},
|
||||
stop: function() {
|
||||
this.desktop._serverpush = null;
|
||||
this.active = false;
|
||||
this.desktop._serverpush = null;
|
||||
if (this._req) {
|
||||
this._req.abort();
|
||||
this._req = null;
|
||||
|
|
Loading…
Reference in New Issue