From 2afdf8b0ca2fe44d4bc810a2bc55f5b65fbf7995 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 21 Feb 2023 02:24:52 +0200 Subject: [PATCH] LH-276: Update producer close event handler --- app.js | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/app.js b/app.js index 6a95259..e99d904 100644 --- a/app.js +++ b/app.js @@ -188,22 +188,21 @@ peers.on('connection', async (socket) => { console.log(`[createRoom] socket.id ${socket.id} callId ${callId}`); if (!videoCalls[callId]) { videoCalls[callId] = { router: await worker.createRouter({ mediaCodecs }) }; - console.log(`[createRoom] Router ID: ${videoCalls[callId].router.id}`); + console.log(`[createRoom] Generate Router ID: ${videoCalls[callId].router.id}`); videoCalls[callId].receiverSocket = socket; } else { videoCalls[callId].initiatorSocket = socket; } socketDetails[socket.id] = callId; // rtpCapabilities is set for callback - console.log('[getRtpCapabilities] callId', callId); callbackResponse = { rtpCapabilities: videoCalls[callId].router.rtpCapabilities, }; } else { - console.log(`[createRoom] missing callId ${callId}`); + console.log(`[createRoom] missing callId: ${callId}`); } } catch (error) { - console.error(`[createRoom] | ERROR | callId ${callId} | error: ${error.message}`); + console.error(`[createRoom] | ERROR | callId: ${callId} | error: ${error.message}`); } finally { callback(callbackResponse); } @@ -272,7 +271,7 @@ peers.on('connection', async (socket) => { const callId = socketDetails[socket.id]; if (typeof rtpParameters === 'string') rtpParameters = JSON.parse(rtpParameters); - console.log(`[transport-produce] kind: ${kind} | socket: ${socket.id} | callId: ${callId}`); + console.log(`[transport-produce] callId: ${callId} | kind: ${kind} | socket: ${socket.id}`); if (kind === 'video') { if (!isInitiator(callId, socket.id)) { @@ -281,10 +280,6 @@ peers.on('connection', async (socket) => { rtpParameters, }); - console.log( - `[transport-produce] receiverVideoProducer Producer ID: ${videoCalls[callId].receiverVideoProducer.id} | kind: ${videoCalls[callId].receiverVideoProducer.kind}` - ); - videoCalls[callId].receiverVideoProducer.on('transportclose', () => { console.log('transport for this producer closed', callId); closeCall(callId); @@ -301,10 +296,6 @@ peers.on('connection', async (socket) => { rtpParameters, }); - console.log( - `[transport-produce] initiatorVideoProducer Producer ID: ${videoCalls[callId].initiatorVideoProducer.id} | kind: ${videoCalls[callId].initiatorVideoProducer.kind}` - ); - videoCalls[callId].initiatorVideoProducer.on('transportclose', () => { console.log('transport for this producer closed', callId); closeCall(callId); @@ -322,10 +313,6 @@ peers.on('connection', async (socket) => { rtpParameters, }); - console.log( - `[transport-produce] receiverAudioProducer Producer ID: ${videoCalls[callId].receiverAudioProducer.id} | kind: ${videoCalls[callId].receiverAudioProducer.kind}` - ); - videoCalls[callId].receiverAudioProducer.on('transportclose', () => { console.log('transport for this producer closed', callId); closeCall(callId); @@ -342,10 +329,6 @@ peers.on('connection', async (socket) => { rtpParameters, }); - console.log( - `[transport-produce] initiatorAudioProducer Producer ID: ${videoCalls[callId].initiatorAudioProducer.id} | kind: ${videoCalls[callId].initiatorAudioProducer.kind}` - ); - videoCalls[callId].initiatorAudioProducer.on('transportclose', () => { console.log('transport for this producer closed', callId); closeCall(callId); @@ -485,7 +468,6 @@ peers.on('connection', async (socket) => { socket.on('close-producer', ({ callId, kind}) => { try { - console.log(`[close-producer] callId: ${callId} | kind: ${kind}`); if (isInitiator(callId, socket.id)) { console.log(`[close-producer] initiator --EMIT--> receiver | callId: ${callId} | kind: ${kind}`); videoCalls[callId].receiverSocket.emit('close-producer', { callId, kind }); @@ -574,7 +556,7 @@ const isInitiator = (callId, socketId) => { */ const createWebRtcTransportLayer = async (callId, callback) => { try { - console.log('[createWebRtcTransportLayer] callId', callId); + console.log(`[createWebRtcTransportLayer] callId: ${callId}`); // https://mediasoup.org/documentation/v3/mediasoup/api/#WebRtcTransportOptions const webRtcTransport_options = { listenIps: [