From 1c3a8bfe1d087faea6e641db5816bda399085043 Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Wed, 8 Feb 2023 01:04:38 +0100 Subject: [PATCH] remove unnecessary double signaling onPeerJoined and prevent second RTCPeer instance for same peerId --- public/scripts/network.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/public/scripts/network.js b/public/scripts/network.js index 6ab4201..baaaced 100644 --- a/public/scripts/network.js +++ b/public/scripts/network.js @@ -467,7 +467,7 @@ class Peer { return; } Events.fire('file-transfer-accepted'); - Events.fire('set-progress', {peerId: this._peerId, progress: 1, status: 'transfer'}); + Events.fire('set-progress', {peerId: this._peerId, progress: 0, status: 'transfer'}); this.sendFiles(); } @@ -644,7 +644,6 @@ class PeersManager { Events.on('files-selected', e => this._onFilesSelected(e.detail)); Events.on('respond-to-files-transfer-request', e => this._onRespondToFileTransferRequest(e.detail)) Events.on('send-text', e => this._onSendText(e.detail)); - Events.on('peer-joined', e => this._onPeerJoined(e.detail)); Events.on('peer-disconnected', e => this._onPeerLeft(e.detail)); Events.on('secret-room-deleted', e => this._onSecretRoomDeleted(e.detail)); Events.on('beforeunload', e => this._onBeforeUnload(e)); @@ -674,6 +673,7 @@ class PeersManager { // if different roomType -> abort if (this.peers[peer.id].roomType !== msg.roomType) return; this.peers[peer.id].refresh(); + return; } this.peers[peer.id] = new RTCPeer(this._server, peer.id, msg.roomType, msg.roomSecret); }) @@ -707,10 +707,6 @@ class PeersManager { this.peers[message.to].sendText(message.text); } - _onPeerJoined(message) { - this._onMessage({sender: message.peer.id, roomType: message.roomType, roomSecret: message.roomSecret}); - } - _onPeerLeft(peerId) { const peer = this.peers[peerId]; delete this.peers[peerId];