浏览代码

Fix debug logging of stanzas

JC Brand 1 年之前
父节点
当前提交
2e27243277
共有 2 个文件被更改,包括 12 次插入1 次删除
  1. 10 1
      src/headless/shared/connection/index.js
  2. 2 0
      src/headless/types/shared/connection/index.d.ts

+ 10 - 1
src/headless/shared/connection/index.js

@@ -30,6 +30,16 @@ export class Connection extends Strophe.Connection {
         this.debouncedReconnect = debounce(this.reconnect, 3000);
     }
 
+    /** @param {Element} body */
+    xmlInput (body) {
+        log.debug(body.outerHTML, 'color: darkgoldenrod');
+    }
+
+    /** @param {Element} body */
+    xmlOutput (body) {
+        log.debug(body.outerHTML, 'color: darkcyan');
+    }
+
     async bind () {
         const { api } = _converse;
         /**
@@ -41,7 +51,6 @@ export class Connection extends Strophe.Connection {
         super.bind();
     }
 
-
     async onDomainDiscovered (response) {
         const { api } = _converse;
         const text = await response.text();

+ 2 - 0
src/headless/types/shared/connection/index.d.ts

@@ -8,6 +8,8 @@ export class Connection extends Connection_base {
     constructor(service: any, options: any);
     send_initial_presence: boolean;
     debouncedReconnect: any;
+    /** @param {Element} body */
+    xmlInput(body: Element): void;
     bind(): Promise<void>;
     onDomainDiscovered(response: any): Promise<void>;
     /**