Execute manual resource binding if necessary

This commit is contained in:
JC Brand 2019-05-30 09:45:41 +02:00
parent 0688907e0d
commit 24956d8dca

View File

@ -849,6 +849,8 @@ _converse.initialize = async function (settings, callback) {
} else if (status === Strophe.Status.DISCONNECTED) {
_converse.setDisconnectionCause(status, message);
_converse.onDisconnected();
} else if (status === Strophe.Status.BINDREQUIRED) {
_converse.bindResource();
} else if (status === Strophe.Status.ERROR) {
_converse.setConnectionStatus(
status,
@ -1089,6 +1091,16 @@ _converse.initialize = async function (settings, callback) {
_converse.api.trigger('setUserJID');
};
this.bindResource = async function () {
/**
* Synchronous event triggered before we send an IQ to bind the user's
* JID resource for this session.
* @event _converse#beforeResourceBinding
*/
await _converse.api.trigger('beforeResourceBinding', {'synchronous': true});
_converse.connection.bind();
};
this.onConnected = function (reconnecting) {
/* Called as soon as a new connection has been established, either
* by logging in or by attaching to an existing BOSH session.