LH-276: Update producer close event handler
This commit is contained in:
parent
c47259225a
commit
f99a4d9849
31
app.js
31
app.js
@ -148,11 +148,10 @@ const closeCall = (callId) => {
|
||||
videoCalls[callId]?.receiverProducerTransport?.close();
|
||||
videoCalls[callId]?.router?.close();
|
||||
delete videoCalls[callId];
|
||||
} else {
|
||||
console.log(`The call with id ${callId} has already been deleted`);
|
||||
console.log(`[closeCall] | callId: ${callId}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(`[closeCall] | ERROR | callid: ${callId} | error: ${error.message}`);
|
||||
console.error(`[closeCall] | ERROR | callId: ${callId} | error: ${error.message}`);
|
||||
}
|
||||
};
|
||||
|
||||
@ -291,11 +290,6 @@ peers.on('connection', async (socket) => {
|
||||
closeCall(callId);
|
||||
});
|
||||
|
||||
// videoCalls[callId].receiverVideoProducer.observer.on("close", () => {
|
||||
// console.log(`[close-producer] receiverVideoProducer receiver --EMIT--> initiator | callId: ${callId} | kind: ${kind}`);
|
||||
// videoCalls[callId].initiatorSocket.emit('close-producer', { callId, kind });
|
||||
// })
|
||||
|
||||
// Send back to the client the Producer's id
|
||||
callback &&
|
||||
callback({
|
||||
@ -316,11 +310,6 @@ peers.on('connection', async (socket) => {
|
||||
closeCall(callId);
|
||||
});
|
||||
|
||||
// videoCalls[callId].initiatorVideoProducer.observer.on("close", () => {
|
||||
// console.log(`[close-producer] initiatorVideoProducer initiator --EMIT--> receiver | callId: ${callId} | kind: ${kind}`);
|
||||
// videoCalls[callId].receiverSocket.emit('close-producer', { callId, kind });
|
||||
// })
|
||||
|
||||
callback &&
|
||||
callback({
|
||||
id: videoCalls[callId].initiatorVideoProducer.id,
|
||||
@ -342,11 +331,6 @@ peers.on('connection', async (socket) => {
|
||||
closeCall(callId);
|
||||
});
|
||||
|
||||
// videoCalls[callId].receiverAudioProducer.observer.on("close", () => {
|
||||
// console.log(`[close-producer] receiverAudioProducer receiver --EMIT--> initiator | callId: ${callId} | kind: ${kind}`);
|
||||
// videoCalls[callId].initiatorSocket.emit('close-producer', { callId, kind });
|
||||
// })
|
||||
|
||||
// Send back to the client the Producer's id
|
||||
callback &&
|
||||
callback({
|
||||
@ -367,11 +351,6 @@ peers.on('connection', async (socket) => {
|
||||
closeCall(callId);
|
||||
});
|
||||
|
||||
// videoCalls[callId].initiatorAudioProducer.observer.on("close", () => {
|
||||
// console.log(`[close-producer] initiatorAudioProducer initiator --EMIT--> receiver | callId: ${callId} | kind: ${kind}`);
|
||||
// videoCalls[callId].receiverSocket.emit('close-producer', { callId, kind });
|
||||
// })
|
||||
|
||||
// Send back to the client the Producer's id
|
||||
callback &&
|
||||
callback({
|
||||
@ -456,7 +435,7 @@ peers.on('connection', async (socket) => {
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`[consume] | ERROR | callId: ${callId} | error: ${error.message}`)
|
||||
console.error(`[consume] | ERROR | callId: ${callId} | error: ${error.message}`);
|
||||
}
|
||||
|
||||
console.log(`[consume] socket ${socket.id} | callId: ${callId} | canConsumeVideo: ${canConsumeVideo} | canConsumeAudio: ${canConsumeAudio}`);
|
||||
@ -508,13 +487,9 @@ peers.on('connection', async (socket) => {
|
||||
try {
|
||||
console.log(`[close-producer] callId: ${callId} | kind: ${kind}`);
|
||||
if (isInitiator(callId, socket.id)) {
|
||||
// if (kind === 'video') {videoCalls[callId].initiatorVideoProducer.close()}
|
||||
// else if (kind === 'audio') videoCalls[callId].initiatorAudioProducer.close()
|
||||
console.log(`[close-producer] initiator --EMIT--> receiver | callId: ${callId} | kind: ${kind}`);
|
||||
videoCalls[callId].receiverSocket.emit('close-producer', { callId, kind });
|
||||
} else {
|
||||
// if (kind === 'video') videoCalls[callId].receiverVideoProducer.close()
|
||||
// else if (kind === 'audio') videoCalls[callId].receiverAudioProducer.close()
|
||||
console.log(`[close-producer] receiver --EMIT--> initiator | callId: ${callId} | kind: ${kind}`);
|
||||
videoCalls[callId].initiatorSocket.emit('close-producer', { callId, kind });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user