MUC: Don't send out unavailable presence when connection is lost.

This commit is contained in:
JC Brand 2016-11-02 14:51:23 +00:00
parent 8fdc664b24
commit e5b2acde06

View File

@ -668,7 +668,17 @@
return converse.connection.send(stanza);
},
cleanup: function () {
this.model.set('connection_status', Strophe.Status.DISCONNECTED);
this.removeHandlers();
},
leave: function(exit_msg) {
if (!converse.connection.connected) {
// Don't send out a stanza if we're not connected.
this.cleanup();
return;
}
var presenceid = converse.connection.getUniqueId();
var presence = $pres({
type: "unavailable",
@ -679,12 +689,10 @@
if (exit_msg !== null) {
presence.c("status", exit_msg);
}
var that = this;
converse.connection.addHandler(
function () {
that.model.set('connection_status', Strophe.Status.DISCONNECTED);
that.removeHandlers();
}, null, "presence", null, presenceid);
this.cleanup.bind(this),
null, "presence", null, presenceid
);
converse.connection.send(presence);
},