瀏覽代碼

Add message debugging switch

Danilo Bargen 8 年之前
父節點
當前提交
88657e05fa
共有 3 個文件被更改,包括 11 次插入0 次删除
  1. 3 0
      src/config.ts
  2. 7 0
      src/services/webclient.ts
  3. 1 0
      src/threema.d.ts

+ 3 - 0
src/config.ts

@@ -29,4 +29,7 @@ export default {
     // Push
     PUSH_URL: 'https://push-web.threema.ch/push',
 
+    // Message debugging
+    MSG_DEBUGGING: false,
+
 } as threema.Config;

+ 7 - 0
src/services/webclient.ts

@@ -478,6 +478,10 @@ export class WebClientService {
                     return;
                 }
 
+                if (this.config.MSG_DEBUGGING) {
+                    this.$log.debug('[Message] Incoming:', message.type, '/', message.subType, message);
+                }
+
                 // Process data
                 this.$rootScope.$apply(() => {
                     this.receive(message);
@@ -2373,6 +2377,9 @@ export class WebClientService {
      */
     private send(message: threema.WireMessage): void {
         this.$log.debug('Sending', message.type + '/' + message.subType, 'message');
+        if (this.config.MSG_DEBUGGING) {
+            this.$log.debug('[Message] Outgoing:', message.type, '/', message.subType, message);
+        }
         const bytes: Uint8Array = this.msgpackEncode(message);
         this.secureDataChannel.send(bytes);
     }

+ 1 - 0
src/threema.d.ts

@@ -391,6 +391,7 @@ declare namespace threema {
         SALTYRTC_HOST_SUFFIX: string | null;
         ICE_SERVERS: RTCIceServer[];
         PUSH_URL: string;
+        MSG_DEBUGGING: boolean;
     }
 
     interface InitialConversationData {