diff --git a/app.js b/app.js index cc3be96..5359aa8 100644 --- a/app.js +++ b/app.js @@ -261,11 +261,6 @@ peers.on('connection', async (socket) => { ? await videoCalls[callId].initiatorProducerTransport.connect({ dtlsParameters }) : await videoCalls[callId].receiverProducerTransport.connect({ dtlsParameters }); - const socketToEmit = isInitiator(callId, socket.id) - ? videoCalls[callId].receiverSocket - : videoCalls[callId].initiatorSocket; - socketToEmit.emit('new-producer', { callId }); - } catch (error) { console.log(`ERROR | transport-connect | callId ${socketDetails[socket.id]} | ${error.message}`); } @@ -371,6 +366,12 @@ peers.on('connection', async (socket) => { }); } } + + const socketToEmit = isInitiator(callId, socket.id) + ? videoCalls[callId].receiverSocket + : videoCalls[callId].initiatorSocket; + socketToEmit.emit('new-producer', { callId }); + } catch (error) { console.log(`ERROR | transport-produce | callId ${socketDetails[socket.id]} | ${error.message}`); }