Moved 'new-producer' in 'transport-produce' handler

This commit is contained in:
Sergiu Toma 2023-01-18 11:49:02 +02:00
parent aca0a6eac0
commit 1da0170261
1 changed files with 6 additions and 5 deletions

11
app.js
View File

@ -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}`);
}