From eece7d2ee3cd8da7b819a1a995b199ec75d3dcba Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Fri, 13 Jan 2023 13:27:59 +0200 Subject: [PATCH] LAPI-675: Added handler for new transport/newproducer/newconsumer --- app.js | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/app.js b/app.js index 6957b2a..91f913b 100644 --- a/app.js +++ b/app.js @@ -280,6 +280,112 @@ peers.on('connection', async socket => { if (typeof rtpParameters === 'string') rtpParameters = JSON.parse(rtpParameters); console.log(`[transport-produce] kind: ${kind} | socket: ${socket.id} | callId: ${callId}`); + + + + + + + + + + + + + + + + + + + + + // videoCalls[callId].router + const router = videoCalls[callId].router; + + + router.observer.on("newtransport", (transport) => + { + console.log( + "new transport created [worker.pid:%d, router.id:%s, transport.id:%s]", + worker.pid, router.id, transport.id); + + transport.observer.on("close", () => + { + console.log("transport closed [transport.id:%s]", transport.id); + }); + + transport.observer.on("newproducer", (producer) => + { + console.log( + "new producer created [worker.pid:%d, router.id:%s, transport.id:%s, producer.id:%s]", + worker.pid, router.id, transport.id, producer.id); + + producer.observer.on("close", () => + { + console.log("producer closed [producer.id:%s]", producer.id); + }); + }); + + transport.observer.on("newconsumer", (consumer) => + { + console.log( + "new consumer created [worker.pid:%d, router.id:%s, transport.id:%s, consumer.id:%s]", + worker.pid, router.id, transport.id, consumer.id); + + consumer.observer.on("close", () => + { + console.log("consumer closed [consumer.id:%s]", consumer.id); + }); + }); + + transport.observer.on("newdataproducer", (dataProducer) => + { + console.log( + "new data producer created [worker.pid:%d, router.id:%s, transport.id:%s, dataProducer.id:%s]", + worker.pid, router.id, transport.id, dataProducer.id); + + dataProducer.observer.on("close", () => + { + console.log("data producer closed [dataProducer.id:%s]", dataProducer.id); + }); + }); + + transport.observer.on("newdataconsumer", (dataConsumer) => + { + console.log( + "new data consumer created [worker.pid:%d, router.id:%s, transport.id:%s, dataConsumer.id:%s]", + worker.pid, router.id, transport.id, dataConsumer.id); + + dataConsumer.observer.on("close", () => + { + console.log("data consumer closed [dataConsumer.id:%s]", dataConsumer.id); + }); + }); + + }); + + + + + + + + + + + + + + + + + + + + + + if (kind === 'video') { if (!isInitiator(callId, socket.id)) { videoCalls[callId].receiverVideoProducer = await videoCalls[callId].receiverProducerTransport.produce({