From d6ef5887ddf616ce69980b6ac256cf32ef294202 Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Fri, 3 Mar 2023 12:38:34 +0100 Subject: [PATCH] move logging of rtc message from class Peer class to overwritten method in class RTCPeer --- public/scripts/network.js | 9 ++++++++- public_included_ws_fallback/scripts/network.js | 13 ++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/public/scripts/network.js b/public/scripts/network.js index e2ad3cc..a905331 100644 --- a/public/scripts/network.js +++ b/public/scripts/network.js @@ -320,7 +320,6 @@ class Peer { return; } message = JSON.parse(message); - console.log('RTC:', message); switch (message.type) { case 'request': this._onFilesTransferRequest(message); @@ -568,6 +567,14 @@ class RTCPeer extends Peer { this._channel = channel; } + _onMessage(message) { + if (typeof message === 'string') { + message = JSON.parse(message); + console.log('RTC:', message); + } + super._onMessage(message); + } + getConnectionHash() { const localDescriptionLines = this._conn.localDescription.sdp.split("\r\n"); const remoteDescriptionLines = this._conn.remoteDescription.sdp.split("\r\n"); diff --git a/public_included_ws_fallback/scripts/network.js b/public_included_ws_fallback/scripts/network.js index c5f3b2f..1397a1a 100644 --- a/public_included_ws_fallback/scripts/network.js +++ b/public_included_ws_fallback/scripts/network.js @@ -324,13 +324,12 @@ class Peer { this.sendJSON({ type: 'progress', progress: progress }); } - _onMessage(message, logMessage = true) { + _onMessage(message) { if (typeof message !== 'string') { this._onChunkReceived(message); return; } message = JSON.parse(message); - if (logMessage) console.log('RTC:', message); switch (message.type) { case 'request': this._onFilesTransferRequest(message); @@ -578,6 +577,14 @@ class RTCPeer extends Peer { this._channel = channel; } + _onMessage(message) { + if (typeof message === 'string') { + message = JSON.parse(message); + console.log('RTC:', message); + } + super._onMessage(message); + } + getConnectionHash() { const localDescriptionLines = this._conn.localDescription.sdp.split("\r\n"); const remoteDescriptionLines = this._conn.remoteDescription.sdp.split("\r\n"); @@ -749,7 +756,7 @@ class PeersManager { _onWsRelay(message) { const messageJSON = JSON.parse(message) if (messageJSON.type === 'ws-chunk') message = base64ToArrayBuffer(messageJSON.chunk); - this.peers[messageJSON.sender.id]._onMessage(message, false) + this.peers[messageJSON.sender.id]._onMessage(message) } _onPeers(msg) {