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);
} else if (!videoCalls[callId].initiatorProducerTransport && isInitiator(callId, socket.id)) {
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 {
console.log(`producerTransport has already been defined | callId ${callId}`);
callback(null);
@ -320,23 +331,22 @@ peers.on('connection', async (socket) => {
console.log('🟢');
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", () => {
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) =>
{
console.log(
"new producer created [worker.pid:%d, router.id:%s, transport.id:%s, producer.id:%s]", producer.id);
// 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);
});
});
// producer.observer.on("close", () => {
// console.log("producer closed [producer.id:%s]", producer.id);
// });
// });
callback &&
callback({