浏览代码

Support sending outgoing messages through relayed data task

Danilo Bargen 7 年之前
父节点
当前提交
1cbdc6f616
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. 10 1
      src/services/webclient.ts

+ 10 - 1
src/services/webclient.ts

@@ -2537,7 +2537,16 @@ export class WebClientService {
             this.$log.debug('[Message] Outgoing:', message.type, '/', message.subType, message);
         }
         const bytes: Uint8Array = this.msgpackEncode(message);
-        this.secureDataChannel.send(bytes);
+        switch (this.chosenTask) {
+            case threema.ChosenTask.WebRTC:
+                // Send bytes through WebRTC DataChannel
+                this.secureDataChannel.send(bytes);
+                break;
+            case threema.ChosenTask.RelayedData:
+                // Send bytes through e2e encrypted WebSocket
+                this.relayedDataTask.sendMessage(bytes);
+                break;
+        }
     }
 
     /**