MUC: Don't send out unavailable presence when connection is lost.
This commit is contained in:
parent
8fdc664b24
commit
e5b2acde06
@ -668,7 +668,17 @@
|
|||||||
return converse.connection.send(stanza);
|
return converse.connection.send(stanza);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cleanup: function () {
|
||||||
|
this.model.set('connection_status', Strophe.Status.DISCONNECTED);
|
||||||
|
this.removeHandlers();
|
||||||
|
},
|
||||||
|
|
||||||
leave: function(exit_msg) {
|
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 presenceid = converse.connection.getUniqueId();
|
||||||
var presence = $pres({
|
var presence = $pres({
|
||||||
type: "unavailable",
|
type: "unavailable",
|
||||||
@ -679,12 +689,10 @@
|
|||||||
if (exit_msg !== null) {
|
if (exit_msg !== null) {
|
||||||
presence.c("status", exit_msg);
|
presence.c("status", exit_msg);
|
||||||
}
|
}
|
||||||
var that = this;
|
|
||||||
converse.connection.addHandler(
|
converse.connection.addHandler(
|
||||||
function () {
|
this.cleanup.bind(this),
|
||||||
that.model.set('connection_status', Strophe.Status.DISCONNECTED);
|
null, "presence", null, presenceid
|
||||||
that.removeHandlers();
|
);
|
||||||
}, null, "presence", null, presenceid);
|
|
||||||
converse.connection.send(presence);
|
converse.connection.send(presence);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user