|
@@ -1,7 +1,7 @@
|
1
|
1
|
/* global $ */
|
2
|
2
|
|
3
|
3
|
import { getLogger } from 'jitsi-meet-logger';
|
4
|
|
-import { $msg, Strophe } from 'strophe.js';
|
|
4
|
+import { $msg, $pres, Strophe } from 'strophe.js';
|
5
|
5
|
import 'strophejs-plugin-disco';
|
6
|
6
|
|
7
|
7
|
import RandomUtil from '../util/RandomUtil';
|
|
@@ -535,6 +535,27 @@ export default class XMPP extends Listenable {
|
535
|
535
|
// comment it in or out depending on whether we want to run with
|
536
|
536
|
// it for some time.
|
537
|
537
|
this.connection.options.sync = true;
|
|
538
|
+
|
|
539
|
+ // This is needed in some browsers where sync xhr sending
|
|
540
|
+ // is disabled by default on unload
|
|
541
|
+ if (navigator.sendBeacon) {
|
|
542
|
+ const body = this.connection._proto._buildBody()
|
|
543
|
+ .attrs({
|
|
544
|
+ type: 'terminate'
|
|
545
|
+ });
|
|
546
|
+ const pres = $pres({
|
|
547
|
+ xmlns: Strophe.NS.CLIENT,
|
|
548
|
+ type: 'unavailable'
|
|
549
|
+ });
|
|
550
|
+
|
|
551
|
+ body.cnode(pres.tree());
|
|
552
|
+
|
|
553
|
+ const res = navigator.sendBeacon(
|
|
554
|
+ `https${this.connection.service}`,
|
|
555
|
+ Strophe.serialize(body.tree()));
|
|
556
|
+
|
|
557
|
+ logger.info(`Successfully send unavailable beacon ${res}`);
|
|
558
|
+ }
|
538
|
559
|
}
|
539
|
560
|
}
|
540
|
561
|
|