|
@@ -12,6 +12,7 @@ import XMPPEvents from '../../service/xmpp/XMPPEvents';
|
12
|
12
|
import Statistics from '../statistics/statistics';
|
13
|
13
|
|
14
|
14
|
import Moderator from './moderator';
|
|
15
|
+import XmppConnection from './XmppConnection';
|
15
|
16
|
|
16
|
17
|
const logger = getLogger(__filename);
|
17
|
18
|
|
|
@@ -110,6 +111,7 @@ export default class ChatRoom extends Listenable {
|
110
|
111
|
this.members = {};
|
111
|
112
|
this.presMap = {};
|
112
|
113
|
this.presHandlers = {};
|
|
114
|
+ this._removeConnListeners = [];
|
113
|
115
|
this.joined = false;
|
114
|
116
|
this.role = null;
|
115
|
117
|
this.focusMucJid = null;
|
|
@@ -184,6 +186,11 @@ export default class ChatRoom extends Listenable {
|
184
|
186
|
|
185
|
187
|
preJoin.then(() => {
|
186
|
188
|
this.sendPresence(true);
|
|
189
|
+ this._removeConnListeners.push(
|
|
190
|
+ this.connection.addEventListener(
|
|
191
|
+ XmppConnection.Events.CONN_STATUS_CHANGED,
|
|
192
|
+ this.onConnStatusChanged.bind(this))
|
|
193
|
+ );
|
187
|
194
|
resolve();
|
188
|
195
|
});
|
189
|
196
|
});
|
|
@@ -362,6 +369,18 @@ export default class ChatRoom extends Listenable {
|
362
|
369
|
});
|
363
|
370
|
}
|
364
|
371
|
|
|
372
|
+ /**
|
|
373
|
+ * Handles Xmpp Connection status updates.
|
|
374
|
+ *
|
|
375
|
+ * @param {Strophe.Status} status - The Strophe connection status.
|
|
376
|
+ */
|
|
377
|
+ onConnStatusChanged(status) {
|
|
378
|
+ // Send cached presence when the XMPP connection is re-established.
|
|
379
|
+ if (status === XmppConnection.Status.CONNECTED) {
|
|
380
|
+ this.sendPresence();
|
|
381
|
+ }
|
|
382
|
+ }
|
|
383
|
+
|
365
|
384
|
/**
|
366
|
385
|
*
|
367
|
386
|
* @param pres
|
|
@@ -1459,6 +1478,9 @@ export default class ChatRoom extends Listenable {
|
1459
|
1478
|
const timeout = setTimeout(() => onMucLeft(true), 5000);
|
1460
|
1479
|
const eventEmitter = this.eventEmitter;
|
1461
|
1480
|
|
|
1481
|
+ this._removeConnListeners.forEach(remove => remove());
|
|
1482
|
+ this._removeConnListeners = [];
|
|
1483
|
+
|
1462
|
1484
|
/**
|
1463
|
1485
|
*
|
1464
|
1486
|
* @param doReject
|