LAPI-675: Added handler for new transport/newproducer/newconsumer

This commit is contained in:
Sergiu Toma 2023-01-13 13:27:59 +02:00
parent ad4c1f27e7
commit eece7d2ee3

106
app.js
View File

@ -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({