From 76d93e97b1a26502b208bc8d092c4cfc4fe50044 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 21 Feb 2023 01:19:51 +0200 Subject: [PATCH] LH-276: Update producer close event handler --- app.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index 5b9cb9e..b9945f6 100644 --- a/app.js +++ b/app.js @@ -492,8 +492,11 @@ peers.on('connection', async (socket) => { socket.on('consumer-resume', () => { try { const callId = socketDetails[socket.id]; - console.log(`[consumer-resume] callId: ${callId}`); - if (isInitiator(callId, socket.id)) { + const isInitiator = isInitiator(callId, socket.id); + console.log(`[consumer-resume] callId: ${callId} | isInitiator: ${isInitiator}`); + console.log('videoCalls[callId]?.receiverConsumerVideo?', videoCalls[callId]?.receiverConsumerVideo); + console.log('videoCalls[callId]?.receiverConsumerAudio', videoCalls[callId]?.receiverConsumerAudio); + if (isInitiator) { videoCalls[callId]?.initiatorConsumerVideo?.resume(); videoCalls[callId]?.initiatorConsumerAudio?.resume(); } else { @@ -501,14 +504,13 @@ peers.on('connection', async (socket) => { videoCalls[callId]?.receiverConsumerAudio?.resume(); } } catch (error) { - console.log(`ERROR | consumer-resume | callId ${socketDetails[socket.id]} | ${error.message}`); + console.error(`[consumer-resume] | ERROR | callId: ${callId} | isInitiator: ${isInitiator} | error: ${error.message}`); } }); socket.on('close-producer', ({ callId, kind}) => { try { - const callId = socketDetails[socket.id]; - console.log(`[close-producer] callId: ${callId} | kind: kind`); + console.log(`[close-producer] callId: ${callId} | kind: ${kind}`); if (isInitiator(callId, socket.id)) { if (kind === 'video') videoCalls[callId].initiatorVideoProducer.close() else if (kind === 'audio') videoCalls[callId].initiatorAudioProducer.close()