瀏覽代碼

Fix URL for sendBeacon. (#980)

* Fix URL for sendBeacon.

* Performs sendBeacon once or connection.disconnect().
dev1
Дамян Минков 6 年之前
父節點
當前提交
3f7613748d
No account linked to committer's email address
共有 1 個文件被更改,包括 11 次插入2 次删除
  1. 11
    2
      modules/xmpp/xmpp.js

+ 11
- 2
modules/xmpp/xmpp.js 查看文件

538
 
538
 
539
                     // This is needed in some browsers where sync xhr sending
539
                     // This is needed in some browsers where sync xhr sending
540
                     // is disabled by default on unload
540
                     // is disabled by default on unload
541
-                    if (navigator.sendBeacon) {
541
+                    if (navigator.sendBeacon && !this.connection.disconnecting
542
+                            && this.connection.connected) {
543
+                        this.connection._changeConnectStatus(Strophe.Status.DISCONNECTING);
544
+                        this.connection.disconnecting = true;
545
+
542
                         const body = this.connection._proto._buildBody()
546
                         const body = this.connection._proto._buildBody()
543
                             .attrs({
547
                             .attrs({
544
                                 type: 'terminate'
548
                                 type: 'terminate'
551
                         body.cnode(pres.tree());
555
                         body.cnode(pres.tree());
552
 
556
 
553
                         const res = navigator.sendBeacon(
557
                         const res = navigator.sendBeacon(
554
-                            `https${this.connection.service}`,
558
+                            `https:${this.connection.service}`,
555
                             Strophe.serialize(body.tree()));
559
                             Strophe.serialize(body.tree()));
556
 
560
 
557
                         logger.info(`Successfully send unavailable beacon ${res}`);
561
                         logger.info(`Successfully send unavailable beacon ${res}`);
562
+
563
+                        this.connection._proto._abortAllRequests();
564
+                        this.connection._doDisconnect();
565
+
566
+                        return;
558
                     }
567
                     }
559
                 }
568
                 }
560
             }
569
             }

Loading…
取消
儲存