Ported disconnect to customer-side, although it doesn't and will problably never work due to the way browsers handle unload()

bzr revid: nicolas.vanhoren@openerp.com-20130204104346-j63yl3chc2gfxdzq
This commit is contained in:
niv-openerp
2013-02-04 11:43:46 +01:00
parent 4c5a9a9d54
commit db3ea1ac3f
4 changed files with 15 additions and 11 deletions
@@ -91,6 +91,7 @@ define(["nova", "jquery", "underscore", "oeclient", "require"], function(nova, $
this.activated = false;
this.users_cache = {};
this.last = null;
this.unload_event_handler = _.bind(this.unload, this);
},
start_polling: function() {
var self = this;
@@ -105,6 +106,7 @@ define(["nova", "jquery", "underscore", "oeclient", "require"], function(nova, $
connection.connector.call("/longpolling/im/activated", {}).then(function(activated) {
if (activated) {
self.activated = true;
$(window).on("unload", self.unload_event_handler);
self.poll();
}
});
@@ -112,6 +114,9 @@ define(["nova", "jquery", "underscore", "oeclient", "require"], function(nova, $
});
});
},
unload: function() {
connection.getModel("im.user").call("im_disconnect", [], {uuid: this.me.get("uuid"), context: {}});
},
ensure_users: function(user_ids) {
var no_cache = {};
_.each(user_ids, function(el) {
@@ -223,6 +228,7 @@ define(["nova", "jquery", "underscore", "oeclient", "require"], function(nova, $
}, this);
},
destroy: function() {
$(window).off("unload", this.unload_event_handler);
$(window).unbind("blur", this.blur_hdl);
$(window).unbind("focus", this.focus_hdl);
nova.DynamicProperties.destroy.call(this);
+1 -1
View File
@@ -15,7 +15,7 @@
},
})(["livesupport", "jquery"], function(livesupport, jQuery) {
jQuery.noConflict();
livesupport.main("http://localhost:8069", "test", "admin", "a");
livesupport.main("http://localhost", "test", "admin", "a");
});
</script>
</head>
+2
View File
@@ -264,6 +264,8 @@ class im_user(osv.osv):
return self._im_change_status(cr, uid, True, uuid or uid, context)
def im_disconnect(self, cr, uid, uuid=None, context=None):
import pudb
pudb.set_trace()
return self._im_change_status(cr, uid, False, uuid or uid, context)
def _im_change_status(self, cr, uid, new_one, uuid=None, context=None):
+6 -10
View File
@@ -50,7 +50,6 @@ openerp.web_im = function(instance) {
this.c_manager.set("right_offset", this.get("right_offset"));
}, this));
this.user_search_dm = new instance.web.DropMisordered();
this.unload_event_handler = _.bind(this.unload, this);
},
start: function() {
this.$el.css("right", -this.$el.outerWidth());
@@ -63,17 +62,8 @@ openerp.web_im = function(instance) {
var self = this;
$(window).on("unload", this.unload_event_handler);
return this.c_manager.start_polling();
},
unload: function() {
return new instance.web.Model("im.user").call("im_disconnect", [], {context: new instance.web.CompoundContext()});
},
destroy: function() {
$(window).off("unload", this.unload_event_handler);
this._super();
},
calc_box: function() {
var $topbar = instance.client.$(".oe_topbar");
var top = $topbar.offset().top + $topbar.height();
@@ -208,6 +198,7 @@ openerp.web_im = function(instance) {
this.activated = false;
this.users_cache = {};
this.last = null;
this.unload_event_handler = _.bind(this.unload, this);
},
start_polling: function() {
var self = this;
@@ -220,12 +211,16 @@ openerp.web_im = function(instance) {
self.rpc("/longpolling/im/activated", {}).then(function(activated) {
if (activated) {
self.activated = true;
$(window).on("unload", self.unload_event_handler);
self.poll();
}
});
});
});
},
unload: function() {
return new instance.web.Model("im.user").call("im_disconnect", [], {context: new instance.web.CompoundContext()});
},
ensure_users: function(user_ids) {
var no_cache = {};
_.each(user_ids, function(el) {
@@ -335,6 +330,7 @@ openerp.web_im = function(instance) {
}, this);
},
destroy: function() {
$(window).off("unload", this.unload_event_handler);
$(window).unbind("blur", this.blur_hdl);
$(window).unbind("focus", this.focus_hdl);
this._super();