LH-276: Update producer close event handler

This commit is contained in:
Sergiu Toma 2023-02-21 01:55:40 +02:00
parent c65dcf1729
commit 7ec9f4ebde

56
app.js
View File

@ -487,32 +487,36 @@ peers.on('connection', async (socket) => {
- 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', () => {
try {
const callId = socketDetails[socket.id];
const isInitiatorValue = isInitiator(callId, socket.id);
console.log(`[consumer-resume] callId: ${callId} | isInitiator: ${isInitiatorValue}`);
if (isInitiatorValue) {
try {
videoCalls[callId].initiatorConsumerVideo && videoCalls[callId].initiatorConsumerVideo.resume();
videoCalls[callId].initiatorConsumerAudio && videoCalls[callId].initiatorConsumerAudio.resume();
} catch (error) {
console.log('sssss', error.message);
}
} else {
try {
// videoCalls[callId].receiverConsumerVideo && videoCalls[callId].receiverConsumerVideo.resume();
// videoCalls[callId].receiverConsumerAudio && videoCalls[callId].receiverConsumerAudio.resume();
} catch (error) {
console.log('sssss22222', error.message);
}
console.log('videoCalls[callId].receiverConsumerVideo', videoCalls[callId].receiverConsumerVideo);
console.log('videoCalls[callId].receiverConsumerAudio', videoCalls[callId].receiverConsumerAudio);
}
} catch (error) {
console.error(`[consumer-resume] | ERROR | callId: ${socketDetails[socket.id]} | isInitiator: ${isInitiator} | error: ${error.message}`);
}
});
try {
socket.on('consumer-resume', () => {
try {
const callId = socketDetails[socket.id];
const isInitiatorValue = isInitiator(callId, socket.id);
console.log(`[consumer-resume] callId: ${callId} | isInitiator: ${isInitiatorValue}`);
if (isInitiatorValue) {
try {
videoCalls[callId].initiatorConsumerVideo && videoCalls[callId].initiatorConsumerVideo.resume();
videoCalls[callId].initiatorConsumerAudio && videoCalls[callId].initiatorConsumerAudio.resume();
} catch (error) {
console.log('sssss', error.message);
}
} else {
try {
// videoCalls[callId].receiverConsumerVideo && videoCalls[callId].receiverConsumerVideo.resume();
// videoCalls[callId].receiverConsumerAudio && videoCalls[callId].receiverConsumerAudio.resume();
} catch (error) {
console.log('sssss22222', error.message);
}
console.log('videoCalls[callId].receiverConsumerVideo', videoCalls[callId].receiverConsumerVideo);
console.log('videoCalls[callId].receiverConsumerAudio', videoCalls[callId].receiverConsumerAudio);
}
} catch (error) {
console.error(`[consumer-resume] | ERROR | callId: ${socketDetails[socket.id]} | isInitiator: ${isInitiator} | error: ${error.message}`);
}
});
} catch (error) {
console.log('akakakakakak', error.mesage);
}
socket.on('close-producer', ({ callId, kind}) => {
try {