Refactor consumer-resume

This commit is contained in:
Sergiu Toma 2023-01-12 12:44:11 +02:00
parent 5bf31d452f
commit d8405eccc7
1 changed files with 7 additions and 12 deletions

19
app.js
View File

@ -441,23 +441,18 @@ peers.on('connection', async socket => {
/*
- Event sent by the consumer after consuming to resume the pause
- When consuming on consumerTransport, it is initially done with paused: true, here we will resume
- When consuming on consumerTransport, it is initially done with paused: true, here we will resume
- For the initiator we resume the initiatorConsumerAUDIO/VIDEO and for receiver the receiverConsumerAUDIO/VIDEO
*/
socket.on('consumer-resume', async () => {
socket.on('consumer-resume',() => {
try {
const callId = socketDetails[socket.id];
console.log(`[consumer-resume] callId ${callId}`)
if (isInitiator(callId, socket.id)) {
console.log('🟩');
console.log(`[consumer-resume] isInitiator true`);
await videoCalls[callId]?.initiatorConsumerVideo?.resume();
await videoCalls[callId]?.initiatorConsumerAudio?.resume();
initiatorConsumerVideo && videoCalls[callId].initiatorConsumerVideo?.resume();
initiatorConsumerAudio && videoCalls[callId].initiatorConsumerAudio?.resume();
} else {
console.log('🟥');
console.log(`[consumer-resume] isInitiator false`);
await videoCalls[callId]?.receiverConsumerVideo?.resume();
await videoCalls[callId]?.receiverConsumerAudio?.resume();
receiverConsumerVideo && videoCalls[callId].receiverConsumerVideo?.resume();
receiverConsumerAudio && videoCalls[callId].receiverConsumerAudio?.resume();
}
} catch (error) {
console.log(`ERROR | consumer-resume | callId ${socketDetails[socket.id]} | ${error.message}`);