diff --git a/app.js b/app.js index 5359aa8..d5c538f 100644 --- a/app.js +++ b/app.js @@ -223,18 +223,18 @@ peers.on('connection', async (socket) => { const callId = socketDetails[socket.id]; console.log(`[createWebRtcTransport] socket ${socket.id} | sender ${sender} | callId ${callId}`); if (sender) { - if (!videoCalls[callId].receiverProducerTransport && !isInitiator(callId, socket.id)) { + if (!isInitiator(callId, socket.id)) { videoCalls[callId].receiverProducerTransport = await createWebRtcTransportLayer(callId, callback); - } else if (!videoCalls[callId].initiatorProducerTransport && isInitiator(callId, socket.id)) { + } else if (isInitiator(callId, socket.id)) { videoCalls[callId].initiatorProducerTransport = await createWebRtcTransportLayer(callId, callback); } else { console.log(`producerTransport has already been defined | callId ${callId}`); callback(null); } } else if (!sender) { - if (!videoCalls[callId].receiverConsumerTransport && !isInitiator(callId, socket.id)) { + if (!isInitiator(callId, socket.id)) { videoCalls[callId].receiverConsumerTransport = await createWebRtcTransportLayer(callId, callback); - } else if (!videoCalls[callId].initiatorConsumerTransport && isInitiator(callId, socket.id)) { + } else if (isInitiator(callId, socket.id)) { videoCalls[callId].initiatorConsumerTransport = await createWebRtcTransportLayer(callId, callback); } } @@ -291,8 +291,8 @@ peers.on('connection', async (socket) => { videoCalls[callId].receiverVideoProducer.on('transportclose', () => { const callId = socketDetails[socket.id]; - console.log('transport for this producer closed', callId); - closeCall(callId); + console.log('[receiverVideoProducer] transport for this producer closed', callId); + // closeCall(callId); }); // Send back to the client the Producer's id @@ -312,8 +312,8 @@ peers.on('connection', async (socket) => { videoCalls[callId].initiatorVideoProducer.on('transportclose', () => { const callId = socketDetails[socket.id]; - console.log('transport for this producer closed', callId); - closeCall(callId); + console.log('[initiatorVideoProducer] transport for this producer closed', callId); + // closeCall(callId); }); callback && @@ -334,8 +334,8 @@ peers.on('connection', async (socket) => { videoCalls[callId].receiverAudioProducer.on('transportclose', () => { const callId = socketDetails[socket.id]; - console.log('transport for this producer closed', callId); - closeCall(callId); + console.log('[receiverAudioProducer] transport for this producer closed', callId); + // closeCall(callId); }); // Send back to the client the Producer's id @@ -355,8 +355,8 @@ peers.on('connection', async (socket) => { videoCalls[callId].initiatorAudioProducer.on('transportclose', () => { const callId = socketDetails[socket.id]; - console.log('transport for this producer closed', callId); - closeCall(callId); + console.log('[initiatorAudioProducer] transport for this producer closed', callId); + // closeCall(callId); }); // Send back to the client the Producer's id