From 5ee9dfc9b11712ab0e71fbb1f05cd5617b6694e9 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Wed, 16 Oct 2013 17:24:48 +0800 Subject: [PATCH] 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. --- .../src/web/js/jawwa/atmosphere/serverpush.js | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/web/js/jawwa/atmosphere/serverpush.js b/org.adempiere.ui.zk/WEB-INF/src/web/js/jawwa/atmosphere/serverpush.js index cce588be08..dd053a4db7 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/web/js/jawwa/atmosphere/serverpush.js +++ b/org.adempiere.ui.zk/WEB-INF/src/web/js/jawwa/atmosphere/serverpush.js @@ -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;