2
0
Эх сурвалжийг харах

Execute manual resource binding if necessary

JC Brand 6 жил өмнө
parent
commit
24956d8dca

+ 12 - 0
src/headless/converse-core.js

@@ -849,6 +849,8 @@ _converse.initialize = async function (settings, callback) {
         } else if (status === Strophe.Status.DISCONNECTED) {
         } else if (status === Strophe.Status.DISCONNECTED) {
             _converse.setDisconnectionCause(status, message);
             _converse.setDisconnectionCause(status, message);
             _converse.onDisconnected();
             _converse.onDisconnected();
+        } else if (status === Strophe.Status.BINDREQUIRED) {
+            _converse.bindResource();
         } else if (status === Strophe.Status.ERROR) {
         } else if (status === Strophe.Status.ERROR) {
             _converse.setConnectionStatus(
             _converse.setConnectionStatus(
                 status,
                 status,
@@ -1089,6 +1091,16 @@ _converse.initialize = async function (settings, callback) {
         _converse.api.trigger('setUserJID');
         _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) {
     this.onConnected = function (reconnecting) {
         /* Called as soon as a new connection has been established, either
         /* Called as soon as a new connection has been established, either
          * by logging in or by attaching to an existing BOSH session.
          * by logging in or by attaching to an existing BOSH session.