diff --git a/app.js b/app.js index ec33e6b..7bf0803 100644 --- a/app.js +++ b/app.js @@ -109,7 +109,7 @@ const mediaCodecs = [ const closeCall = (callId) => { try { - if (videoCalls[callId]) { + if (callId && videoCalls[callId]) { videoCalls[callId].producer?.close(); videoCalls[callId].consumer?.close(); videoCalls[callId]?.consumerTransport?.close(); @@ -299,14 +299,14 @@ peers.on('connection', async socket => { videoCalls[callId].consumer.on('transportclose', () => { const callId = socketDetails[socket.id]; console.log('transport close from consumer', callId); - closeCall(); + closeCall(callId); }); // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-producerclose videoCalls[callId].consumer.on('producerclose', () => { const callId = socketDetails[socket.id]; console.log('producer of consumer closed', callId); - closeCall(); + closeCall(callId); }); // From the consumer extract the following params to send back to the Client