LH-276: Update producer close enent handler

This commit is contained in:
Sergiu Toma 2023-02-20 20:10:09 +02:00
parent ea1c8e7e80
commit 1fb5df4cde

32
app.js
View File

@ -227,6 +227,17 @@ peers.on('connection', async (socket) => {
videoCalls[callId].receiverProducerTransport = await createWebRtcTransportLayer(callId, callback); videoCalls[callId].receiverProducerTransport = await createWebRtcTransportLayer(callId, callback);
} else if (!videoCalls[callId].initiatorProducerTransport && isInitiator(callId, socket.id)) { } else if (!videoCalls[callId].initiatorProducerTransport && isInitiator(callId, socket.id)) {
videoCalls[callId].initiatorProducerTransport = await createWebRtcTransportLayer(callId, callback); videoCalls[callId].initiatorProducerTransport = await createWebRtcTransportLayer(callId, callback);
videoCalls[callId].initiatorProducerTransport.observer.on("newproducer", (producer) =>
{
console.log(
"------------------new producer created [worker.pid:%d, router.id:%s, transport.id:%s, producer.id:%s]", producer.id);
producer.observer.on("close", () => {
console.log("-------------------producer closed [producer.id:%s]", producer.id);
});
});
} else { } else {
console.log(`producerTransport has already been defined | callId ${callId}`); console.log(`producerTransport has already been defined | callId ${callId}`);
callback(null); callback(null);
@ -320,23 +331,22 @@ peers.on('connection', async (socket) => {
console.log('🟢'); console.log('🟢');
videoCalls[callId].initiatorVideoProducer.on('close', () => { videoCalls[callId].initiatorVideoProducer.on('close', () => {
console.log('1 initiatorVideoProducer for this producer closed', callId); console.log('===================1 initiatorVideoProducer for this producer closed', callId);
}); });
videoCalls[callId].initiatorVideoProducer.observer.on("close", () => { videoCalls[callId].initiatorVideoProducer.observer.on("close", () => {
console.log('2 initiatorVideoProducer for this producer closed', callId); console.log('====================2 initiatorVideoProducer for this producer closed', callId);
}) })
videoCalls[callId].initiatorProducerTransport.observer.on("newproducer", (producer) => // videoCalls[callId].initiatorProducerTransport.observer.on("newproducer", (producer) =>
{ // {
console.log( // console.log(
"new producer created [worker.pid:%d, router.id:%s, transport.id:%s, producer.id:%s]", producer.id); // "new producer created [worker.pid:%d, router.id:%s, transport.id:%s, producer.id:%s]", producer.id);
producer.observer.on("close", () => // producer.observer.on("close", () => {
{ // console.log("producer closed [producer.id:%s]", producer.id);
console.log("producer closed [producer.id:%s]", producer.id); // });
}); // });
});
callback && callback &&
callback({ callback({