Created
December 14, 2017 22:58
-
-
Save blaggacao/d52f852a8bda27885604770193852406 to your computer and use it in GitHub Desktop.
Fix polling issue son POS Multisession
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addons/bus/static/src/js/bus.js | 2 +- | |
1 file changed, 1 insertion(+), 1 deletion(-) | |
diff --git a/addons/bus/static/src/js/bus.js b/addons/bus/static/src/js/bus.js | |
index a79c750..f77522b 100644 | |
--- a/addons/bus/static/src/js/bus.js | |
+++ b/addons/bus/static/src/js/bus.js | |
@@ -76,7 +76,7 @@ bus.Bus = Widget.extend({ | |
this.last_partners_presence_check = now; | |
} | |
var data = {channels: self.channels, last: self.last, options: options}; | |
- session.rpc('/longpolling/poll', data, {shadow : true}).then(function(result) { | |
+ session.rpc('/longpolling/poll', data, {shadow : true, timeout:60000}).then(function(result) { | |
self.on_notification(result); | |
if(!self.stop){ | |
self.poll(); | |
.../pos_multi_session/static/src/js/pos_multi_session.js | 7 ++++--- | |
1 file changed, 4 insertions(+), 3 deletions(-) | |
diff --git a/it-projects-llc/pos_multi_session/static/src/js/pos_multi_session.js b/it-projects-llc/pos_multi_session/static/src/js/pos_multi_session.js | |
index 9d0d158..e6c31ba 100644 | |
--- a/it-projects-llc/pos_multi_session/static/src/js/pos_multi_session.js | |
+++ b/it-projects-llc/pos_multi_session/static/src/js/pos_multi_session.js | |
@@ -531,13 +531,13 @@ odoo.define('pos_multi_session', function(require){ | |
return openerp.session.rpc("/pos_multi_session/update", { | |
multi_session_id: self.pos.config.multi_session_id[0], | |
message: message | |
- }); | |
+ },{timeout:2500}); | |
}; | |
return send_it().fail(function (error, e) { | |
if (self.pos.debug){ | |
console.log('MS', self.pos.config.name, 'failed request #'+current_send_number+':', error.message); | |
} | |
- if(error.message === 'XmlHttpRequestError ') { | |
+ if(error.message.startsWith('XmlHttpRequestError ')) { | |
self.client_online = false; | |
e.preventDefault(); | |
self.pos.longpolling_connection.network_is_off(); | |
@@ -579,6 +579,7 @@ odoo.define('pos_multi_session', function(require){ | |
clearInterval(self.offline_sync_all_timer); | |
self.offline_sync_all_timer = false; | |
} | |
+ self.pos.longpolling_connection.network_is_on(); | |
}); | |
}, | |
destroy_removed_orders: function(server_orders_uid) { | |
@@ -621,7 +622,7 @@ odoo.define('pos_multi_session', function(require){ | |
var self = this; | |
self.offline_sync_all_timer = setInterval(function(){ | |
self.request_sync_all(); | |
- }, 5000); | |
+ }, 5000 + (Math.floor((Math.random()*10)+1)*1000)); | |
}, | |
no_connection_warning: function(){ | |
var warning_message = _t("No connection to the server. You can create new orders only. It is forbidden to modify existing orders."); | |
it-projects-llc/pos_longpolling/static/src/js/pos_longpolling.js | 6 +++++- | |
1 file changed, 5 insertions(+), 1 deletion(-) | |
diff --git a/it-projects-llc/pos_longpolling/static/src/js/pos_longpolling.js b/it-projects-llc/pos_longpolling/static/src/js/pos_longpolling.js | |
index f540b29..bbec5a8 100644 | |
--- a/it-projects-llc/pos_longpolling/static/src/js/pos_longpolling.js | |
+++ b/it-projects-llc/pos_longpolling/static/src/js/pos_longpolling.js | |
@@ -157,9 +157,13 @@ odoo.define('pos_longpolling', function(require){ | |
send: function() { | |
var self = this; | |
this.response_status = false; | |
- openerp.session.rpc("/pos_longpolling/update", {message: "PING", pos_id: self.pos.config.id}).then(function(){ | |
+ openerp.session.rpc("/pos_longpolling/update", {message: "PING", pos_id: self.pos.config.id},{timeout:2500}).then(function(){ | |
/* If the value "response_status" is true, then the poll message came earlier | |
if the value is false you need to start the response timer*/ | |
+ if (self.pos.debug){ | |
+ var host = openerp.session.origin_server ? openerp.session.origin : openerp.session.prefix | |
+ console.log('POS LONGPOLLING', self.pos.config.name, host, "PING"); | |
+ } | |
if (!self.response_status) { | |
self.response_timer(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment