|
|
@@ -23,18 +23,18 @@ import XMPPEvents from '../../service/xmpp/XMPPEvents';
|
|
23
|
23
|
const logger = getLogger(__filename);
|
|
24
|
24
|
|
|
25
|
25
|
/**
|
|
26
|
|
- *
|
|
27
|
|
- * @param token
|
|
28
|
|
- * @param bosh
|
|
|
26
|
+ * Creates XMPP connection.
|
|
|
27
|
+ * @param {string} [token] - JWT token used for authentication(JWT authentication module must be enabled in Prosody).
|
|
|
28
|
+ * @param {string} serviceUrl - The service URL for XMPP connection.
|
|
29
|
29
|
*/
|
|
30
|
|
-function createConnection(token, bosh = '/http-bind') {
|
|
|
30
|
+function createConnection(token, serviceUrl = '/http-bind') {
|
|
31
|
31
|
// Append token as URL param
|
|
32
|
32
|
if (token) {
|
|
33
|
33
|
// eslint-disable-next-line no-param-reassign
|
|
34
|
|
- bosh += `${bosh.indexOf('?') === -1 ? '?' : '&'}token=${token}`;
|
|
|
34
|
+ serviceUrl += `${serviceUrl.indexOf('?') === -1 ? '?' : '&'}token=${token}`;
|
|
35
|
35
|
}
|
|
36
|
36
|
|
|
37
|
|
- const conn = new Strophe.Connection(bosh);
|
|
|
37
|
+ const conn = new Strophe.Connection(serviceUrl);
|
|
38
|
38
|
|
|
39
|
39
|
// The default maxRetries is 5, which is too long.
|
|
40
|
40
|
conn.maxRetries = 3;
|
|
|
@@ -67,6 +67,9 @@ export default class XMPP extends Listenable {
|
|
67
|
67
|
/**
|
|
68
|
68
|
* FIXME describe all options
|
|
69
|
69
|
* @param {Object} options
|
|
|
70
|
+ * @param {String} options.serviceUrl - URL passed to the XMPP client which will be used to establish XMPP
|
|
|
71
|
+ * connection with the server.
|
|
|
72
|
+ * @param {String} options.bosh - Deprecated, use {@code serviceUrl}.
|
|
70
|
73
|
* @param {Array<Object>} options.p2pStunServers see
|
|
71
|
74
|
* {@link JingleConnectionPlugin} for more details.
|
|
72
|
75
|
* @param token
|
|
|
@@ -81,7 +84,8 @@ export default class XMPP extends Listenable {
|
|
81
|
84
|
this.authenticatedUser = false;
|
|
82
|
85
|
this._initStrophePlugins(this);
|
|
83
|
86
|
|
|
84
|
|
- this.connection = createConnection(token, options.bosh);
|
|
|
87
|
+ // FIXME remove deprecated bosh option at some point
|
|
|
88
|
+ this.connection = createConnection(token, options.serviceUrl || options.bosh);
|
|
85
|
89
|
|
|
86
|
90
|
this._lastSuccessTracker = new LastSuccessTracker();
|
|
87
|
91
|
this._lastSuccessTracker.startTracking(this.connection);
|