From f99a4d984943a057c9be5b14360421c193930d77 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 21 Feb 2023 02:16:52 +0200 Subject: [PATCH] LH-276: Update producer close event handler --- app.js | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/app.js b/app.js index 2e1ce3f..6a95259 100644 --- a/app.js +++ b/app.js @@ -148,11 +148,10 @@ const closeCall = (callId) => { videoCalls[callId]?.receiverProducerTransport?.close(); videoCalls[callId]?.router?.close(); delete videoCalls[callId]; - } else { - console.log(`The call with id ${callId} has already been deleted`); + console.log(`[closeCall] | callId: ${callId}`); } } catch (error) { - console.log(`[closeCall] | ERROR | callid: ${callId} | error: ${error.message}`); + console.error(`[closeCall] | ERROR | callId: ${callId} | error: ${error.message}`); } }; @@ -291,11 +290,6 @@ peers.on('connection', async (socket) => { closeCall(callId); }); - // videoCalls[callId].receiverVideoProducer.observer.on("close", () => { - // console.log(`[close-producer] receiverVideoProducer receiver --EMIT--> initiator | callId: ${callId} | kind: ${kind}`); - // videoCalls[callId].initiatorSocket.emit('close-producer', { callId, kind }); - // }) - // Send back to the client the Producer's id callback && callback({ @@ -316,11 +310,6 @@ peers.on('connection', async (socket) => { closeCall(callId); }); - // videoCalls[callId].initiatorVideoProducer.observer.on("close", () => { - // console.log(`[close-producer] initiatorVideoProducer initiator --EMIT--> receiver | callId: ${callId} | kind: ${kind}`); - // videoCalls[callId].receiverSocket.emit('close-producer', { callId, kind }); - // }) - callback && callback({ id: videoCalls[callId].initiatorVideoProducer.id, @@ -342,11 +331,6 @@ peers.on('connection', async (socket) => { closeCall(callId); }); - // videoCalls[callId].receiverAudioProducer.observer.on("close", () => { - // console.log(`[close-producer] receiverAudioProducer receiver --EMIT--> initiator | callId: ${callId} | kind: ${kind}`); - // videoCalls[callId].initiatorSocket.emit('close-producer', { callId, kind }); - // }) - // Send back to the client the Producer's id callback && callback({ @@ -367,11 +351,6 @@ peers.on('connection', async (socket) => { closeCall(callId); }); - // videoCalls[callId].initiatorAudioProducer.observer.on("close", () => { - // console.log(`[close-producer] initiatorAudioProducer initiator --EMIT--> receiver | callId: ${callId} | kind: ${kind}`); - // videoCalls[callId].receiverSocket.emit('close-producer', { callId, kind }); - // }) - // Send back to the client the Producer's id callback && callback({ @@ -456,7 +435,7 @@ peers.on('connection', async (socket) => { }); } } catch (error) { - console.error(`[consume] | ERROR | callId: ${callId} | error: ${error.message}`) + console.error(`[consume] | ERROR | callId: ${callId} | error: ${error.message}`); } console.log(`[consume] socket ${socket.id} | callId: ${callId} | canConsumeVideo: ${canConsumeVideo} | canConsumeAudio: ${canConsumeAudio}`); @@ -508,13 +487,9 @@ peers.on('connection', async (socket) => { try { 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() console.log(`[close-producer] initiator --EMIT--> receiver | callId: ${callId} | kind: ${kind}`); videoCalls[callId].receiverSocket.emit('close-producer', { callId, kind }); } else { - // if (kind === 'video') videoCalls[callId].receiverVideoProducer.close() - // else if (kind === 'audio') videoCalls[callId].receiverAudioProducer.close() console.log(`[close-producer] receiver --EMIT--> initiator | callId: ${callId} | kind: ${kind}`); videoCalls[callId].initiatorSocket.emit('close-producer', { callId, kind }); }