LH-276: Update producer close event handler

This commit is contained in:
Sergiu Toma 2023-02-21 01:12:32 +02:00
parent cb14061b94
commit 2098fbdd89

4
app.js
View File

@ -388,7 +388,7 @@ peers.on('connection', async (socket) => {
// callId - Id of the call // callId - Id of the call
// kind - producer type: audio/video // kind - producer type: audio/video
socketToEmit.emit('new-producer', { callId, kind }); socketToEmit?.emit('new-producer', { callId, kind });
} catch (error) { } catch (error) {
console.log(`ERROR | transport-produce | callId ${socketDetails[socket.id]} | ${error.message}`); console.log(`ERROR | transport-produce | callId ${socketDetails[socket.id]} | ${error.message}`);
} }
@ -510,11 +510,9 @@ peers.on('connection', async (socket) => {
const callId = socketDetails[socket.id]; 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 (isInitiator(callId, socket.id)) {
console.log(`[close-producer] initiator`);
if (kind === 'video') videoCalls[callId].initiatorVideoProducer.close() if (kind === 'video') videoCalls[callId].initiatorVideoProducer.close()
else if (kind === 'audio') videoCalls[callId].initiatorAudioProducer.close() else if (kind === 'audio') videoCalls[callId].initiatorAudioProducer.close()
} else { } else {
console.log(`[close-producer] receiver`);
if (kind === 'video') videoCalls[callId].receiverVideoProducer.close() if (kind === 'video') videoCalls[callId].receiverVideoProducer.close()
else if (kind === 'audio') videoCalls[callId].receiverAudioProducer.close() else if (kind === 'audio') videoCalls[callId].receiverAudioProducer.close()
} }