From bfb5aa8546023e185b2093186239ca51f8893507 Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Fri, 3 Mar 2023 16:36:55 +0100 Subject: [PATCH] fix overwrite method _onMessage of class RTCPeer --- public/scripts/network.js | 19 +++++++++---------- .../scripts/network.js | 19 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/public/scripts/network.js b/public/scripts/network.js index 998290e..8e27f21 100644 --- a/public/scripts/network.js +++ b/public/scripts/network.js @@ -319,25 +319,25 @@ class Peer { this._onChunkReceived(message); return; } - message = JSON.parse(message); - switch (message.type) { + const messageJSON = JSON.parse(message); + switch (messageJSON.type) { case 'request': - this._onFilesTransferRequest(message); + this._onFilesTransferRequest(messageJSON); break; case 'header': - this._onFilesHeader(message); + this._onFilesHeader(messageJSON); break; case 'partition': - this._onReceivedPartitionEnd(message); + this._onReceivedPartitionEnd(messageJSON); break; case 'partition-received': this._sendNextPartition(); break; case 'progress': - this._onDownloadProgress(message.progress); + this._onDownloadProgress(messageJSON.progress); break; case 'files-transfer-response': - this._onFileTransferRequestResponded(message); + this._onFileTransferRequestResponded(messageJSON); break; case 'file-transfer-complete': this._onFileTransferCompleted(); @@ -346,7 +346,7 @@ class Peer { this._onMessageTransferCompleted(); break; case 'text': - this._onTextReceived(message); + this._onTextReceived(messageJSON); break; } } @@ -570,8 +570,7 @@ class RTCPeer extends Peer { _onMessage(message) { if (typeof message === 'string') { - message = JSON.parse(message); - console.log('RTC:', message); + console.log('RTC:', JSON.parse(message)); } super._onMessage(message); } diff --git a/public_included_ws_fallback/scripts/network.js b/public_included_ws_fallback/scripts/network.js index b606c7a..bcd7df6 100644 --- a/public_included_ws_fallback/scripts/network.js +++ b/public_included_ws_fallback/scripts/network.js @@ -329,25 +329,25 @@ class Peer { this._onChunkReceived(message); return; } - message = JSON.parse(message); - switch (message.type) { + const messageJSON = JSON.parse(message); + switch (messageJSON.type) { case 'request': - this._onFilesTransferRequest(message); + this._onFilesTransferRequest(messageJSON); break; case 'header': - this._onFilesHeader(message); + this._onFilesHeader(messageJSON); break; case 'partition': - this._onReceivedPartitionEnd(message); + this._onReceivedPartitionEnd(messageJSON); break; case 'partition-received': this._sendNextPartition(); break; case 'progress': - this._onDownloadProgress(message.progress); + this._onDownloadProgress(messageJSON.progress); break; case 'files-transfer-response': - this._onFileTransferRequestResponded(message); + this._onFileTransferRequestResponded(messageJSON); break; case 'file-transfer-complete': this._onFileTransferCompleted(); @@ -356,7 +356,7 @@ class Peer { this._onMessageTransferCompleted(); break; case 'text': - this._onTextReceived(message); + this._onTextReceived(messageJSON); break; } } @@ -580,8 +580,7 @@ class RTCPeer extends Peer { _onMessage(message) { if (typeof message === 'string') { - message = JSON.parse(message); - console.log('RTC:', message); + console.log('RTC:', JSON.parse(message)); } super._onMessage(message); }