From 69b32f3d12019536c07c4e1ea5202ee6f27603f6 Mon Sep 17 00:00:00 2001 From: Miroslav Pejic Date: Tue, 12 Sep 2023 09:36:58 +0200 Subject: [PATCH] [mirotalksfu] - fix participants cmd --- app/src/Server.js | 4 ++++ public/js/RoomClient.js | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/app/src/Server.js b/app/src/Server.js index 1aa2ee3c..43848efc 100644 --- a/app/src/Server.js +++ b/app/src/Server.js @@ -573,6 +573,10 @@ function startServer() { log.error('Client error', error); socket.destroy(); }); + socket.on('error', (err) => { + log.error('Socket error:', err); + socket.destroy(); + }); socket.on('createRoom', async ({ room_id }, callback) => { socket.room_id = room_id; diff --git a/public/js/RoomClient.js b/public/js/RoomClient.js index 8b399e59..848395a6 100644 --- a/public/js/RoomClient.js +++ b/public/js/RoomClient.js @@ -4505,6 +4505,42 @@ class RoomClient { if (!this.thereIsParticipants()) { if (info) return this.userLog('info', 'No participants detected', 'top-end'); } + switch (action) { + case 'mute': + const peerAudioStatus = this.getId(data.peer_id + '__audio'); + if (!peerAudioStatus || peerAudioStatus.className == html.audioOff) { + return this.userLog( + 'info', + 'The participant has been muted, and only they have the ability to unmute themselves', + 'top-end', + ); + } + break; + case 'hide': + const peerVideoOff = this.getId(data.peer_id + '__videoOff'); + if (peerVideoOff) { + return this.userLog( + 'info', + 'The participant is currently hidden, and only they have the option to unhide themselves', + 'top-end', + ); + } + case 'stop': + const peerScreenButton = this.getId(id); + if (peerScreenButton) { + const peerScreenStatus = peerScreenButton.querySelector('i'); + if (peerScreenStatus && peerScreenStatus.style.color == 'red') { + return this.userLog( + 'info', + 'Screen not shared, only the participant can initiate sharing', + 'top-end', + ); + } + } + break; + default: + break; + } this.confirmPeerAction(action, data); } else { switch (action) { @@ -4667,7 +4703,6 @@ class RoomClient { if (result.isConfirmed) { muteHideStopConfirmed = true; if (!data.broadcast) { - this.socket.emit('peerAction', data); switch (action) { case 'mute': let peerAudioButton = this.getId(data.peer_id + '___pAudio'); @@ -4682,6 +4717,7 @@ class RoomClient { default: break; } + this.socket.emit('peerAction', data); } else { this.socket.emit('peerAction', data); let actionButton = this.getId(action + 'AllButton');