[FIX] bus, im_chat : disabled realtime status notification, replace it with rpc calls and set random retry delay on bus (longpolling)

This commit is contained in:
Jérome Maes 2014-08-26 19:04:00 +02:00
parent d0315f1b5c
commit cc7178b019
3 changed files with 13 additions and 8 deletions

View File

@ -1,7 +1,7 @@
(function() {
var bus = openerp.bus = {};
bus.ERROR_DELAY = 30000;
bus.ERROR_DELAY = 10000;
bus.Bus = openerp.Widget.extend({
init: function(){
@ -24,7 +24,8 @@
_.each(result, _.bind(self.on_notification, self));
self.poll();
}, function(unused, e) {
setTimeout(_.bind(self.poll, self), bus.ERROR_DELAY);
// random delay to avoid massive longpolling
setTimeout(_.bind(self.poll, self), bus.ERROR_DELAY + (Math.floor((Math.random()*20)+1)*1000));
});
},
on_notification: function(notification) {

View File

@ -328,8 +328,10 @@ class Controller(openerp.addons.bus.bus.Controller):
if request.session.uid:
registry, cr, uid, context = request.registry, request.cr, request.session.uid, request.context
registry.get('im_chat.presence').update(cr, uid, ('im_presence' in options), context=context)
# listen to connection and disconnections
channels.append((request.db,'im_chat.presence'))
## For performance issue, the real time status notification is disabled. This means a change of status are still braoadcasted
## but not received by anyone. Otherwise, all listening user restart their longpolling at the same time and cause a 'ConnectionPool Full Error'
## since there is not enought cursors for everyone. Now, when a user open his list of users, an RPC call is made to update his user status list.
##channels.append((request.db,'im_chat.presence'))
# channel to receive message
channels.append((request.db,'im_chat.session', request.uid))
return super(Controller, self)._poll(dbname, channels, last, options)

View File

@ -471,8 +471,8 @@
$(window).resize(_.bind(this.calc_box, this));
this.calc_box();
this.on("change:current_search", this, this.search_changed);
this.search_changed();
this.on("change:current_search", this, this.search_users_status);
this.search_users_status();
// add a drag & drop listener
self.c_manager.on("im_session_activated", self, function(conv) {
@ -505,7 +505,7 @@
input_change: function() {
this.set("current_search", this.$(".oe_im_searchbox").val());
},
search_changed: function(e) {
search_users_status: function(e) {
var user_model = new openerp.web.Model("res.users");
var self = this;
return this.user_search_dm.add(user_model.call("im_search", [this.get("current_search"),
@ -540,10 +540,12 @@
right: -this.$el.outerWidth(),
}, opt);
} else {
if (! openerp.bus.bus.activated) {
if (! openerp.bus.bus.activated) {
this.do_warn("Instant Messaging is not activated on this server. Try later.", "");
return;
}
// update the list of user status when show the IM
this.search_users_status();
this.$el.animate({
right: 0,
}, opt);