瀏覽代碼

connection: Re-add `debouncedReconnect`

JC Brand 4 年之前
父節點
當前提交
cd84feefff
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      src/headless/connection.js

+ 6 - 1
src/headless/connection.js

@@ -4,7 +4,7 @@ import u from '@converse/headless/utils/core';
 import { Strophe } from 'strophe.js/src/core';
 import { __ } from './i18n';
 import { _converse, api, clearSession, tearDown } from "./converse-core";
-import { isElement, noop } from 'lodash';
+import { debounce, isElement, noop } from 'lodash';
 
 
 const BOSH_WAIT = 59;
@@ -17,6 +17,11 @@ const BOSH_WAIT = 59;
  */
 export class Connection extends Strophe.Connection {
 
+    constructor (service, options) {
+        super(service, options);
+        this.debouncedReconnect = debounce(this.reconnect, 2000);
+    }
+
     static generateResource () {
         return `/converse.js-${Math.floor(Math.random()*139749528).toString()}`;
     }