|
@@ -119,11 +119,16 @@ export default class XMPP extends Listenable {
|
119
|
119
|
|
120
|
120
|
/**
|
121
|
121
|
* Receive connection status changes and handles them.
|
122
|
|
- * @password {string} the password passed in connect method
|
123
|
|
- * @status the connection status
|
124
|
|
- * @msg message
|
|
122
|
+ *
|
|
123
|
+ * @param {Object} credentials
|
|
124
|
+ * @param {string} credentials.jid - The user's XMPP ID passed to the
|
|
125
|
+ * connect method. For example, 'user@xmpp.com'.
|
|
126
|
+ * @param {string} credentials.password - The password passed to the connect
|
|
127
|
+ * method.
|
|
128
|
+ * @param {string} status - One of Strophe's connection status strings.
|
|
129
|
+ * @param {string} [msg] - The connection error message provided by Strophe.
|
125
|
130
|
*/
|
126
|
|
- connectionHandler(password, status, msg) {
|
|
131
|
+ connectionHandler(credentials = {}, status, msg) {
|
127
|
132
|
const now = window.performance.now();
|
128
|
133
|
const statusStr = Strophe.getStatusString(status).toLowerCase();
|
129
|
134
|
|
|
@@ -153,7 +158,7 @@ export default class XMPP extends Listenable {
|
153
|
158
|
}
|
154
|
159
|
});
|
155
|
160
|
|
156
|
|
- if (password) {
|
|
161
|
+ if (credentials.password) {
|
157
|
162
|
this.authenticatedUser = true;
|
158
|
163
|
}
|
159
|
164
|
if (this.connection && this.connection.connected
|
|
@@ -175,7 +180,7 @@ export default class XMPP extends Listenable {
|
175
|
180
|
// Stop ping interval
|
176
|
181
|
this.connection.ping.stopInterval();
|
177
|
182
|
const wasIntentionalDisconnect = this.disconnectInProgress;
|
178
|
|
- const errMsg = msg ? msg : this.lastErrorMsg;
|
|
183
|
+ const errMsg = msg || this.lastErrorMsg;
|
179
|
184
|
|
180
|
185
|
this.disconnectInProgress = false;
|
181
|
186
|
if (this.anonymousConnectionFailed) {
|
|
@@ -206,19 +211,21 @@ export default class XMPP extends Listenable {
|
206
|
211
|
this.eventEmitter.emit(
|
207
|
212
|
JitsiConnectionEvents.CONNECTION_FAILED,
|
208
|
213
|
JitsiConnectionErrors.SERVER_ERROR,
|
209
|
|
- errMsg ? errMsg : 'server-error');
|
|
214
|
+ errMsg || 'server-error');
|
210
|
215
|
} else {
|
211
|
216
|
this.eventEmitter.emit(
|
212
|
217
|
JitsiConnectionEvents.CONNECTION_FAILED,
|
213
|
218
|
JitsiConnectionErrors.CONNECTION_DROPPED_ERROR,
|
214
|
|
- errMsg ? errMsg : 'connection-dropped-error');
|
|
219
|
+ errMsg || 'connection-dropped-error');
|
215
|
220
|
}
|
216
|
221
|
}
|
217
|
222
|
} else if (status === Strophe.Status.AUTHFAIL) {
|
218
|
223
|
// wrong password or username, prompt user
|
219
|
|
- this.eventEmitter.emit(JitsiConnectionEvents.CONNECTION_FAILED,
|
220
|
|
- JitsiConnectionErrors.PASSWORD_REQUIRED);
|
221
|
|
-
|
|
224
|
+ this.eventEmitter.emit(
|
|
225
|
+ JitsiConnectionEvents.CONNECTION_FAILED,
|
|
226
|
+ JitsiConnectionErrors.PASSWORD_REQUIRED,
|
|
227
|
+ msg,
|
|
228
|
+ credentials);
|
222
|
229
|
}
|
223
|
230
|
}
|
224
|
231
|
|
|
@@ -258,8 +265,13 @@ export default class XMPP extends Listenable {
|
258
|
265
|
this.anonymousConnectionFailed = false;
|
259
|
266
|
this.connectionFailed = false;
|
260
|
267
|
this.lastErrorMsg = undefined;
|
261
|
|
- this.connection.connect(jid, password,
|
262
|
|
- this.connectionHandler.bind(this, password));
|
|
268
|
+ this.connection.connect(
|
|
269
|
+ jid,
|
|
270
|
+ password,
|
|
271
|
+ this.connectionHandler.bind(this, {
|
|
272
|
+ jid,
|
|
273
|
+ password
|
|
274
|
+ }));
|
263
|
275
|
}
|
264
|
276
|
|
265
|
277
|
/**
|
|
@@ -275,7 +287,10 @@ export default class XMPP extends Listenable {
|
275
|
287
|
logger.log(`(TIME) Strophe Attaching\t:${now}`);
|
276
|
288
|
this.connection.attach(options.jid, options.sid,
|
277
|
289
|
parseInt(options.rid, 10) + 1,
|
278
|
|
- this.connectionHandler.bind(this, options.password));
|
|
290
|
+ this.connectionHandler.bind(this, {
|
|
291
|
+ jid: options.jid,
|
|
292
|
+ password: options.password
|
|
293
|
+ }));
|
279
|
294
|
}
|
280
|
295
|
|
281
|
296
|
/**
|