From f21a5f28ab775105044cba78a8493745666ba243 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 21 Feb 2023 01:26:05 +0200 Subject: [PATCH] LH-276: Update producer close event handler --- app.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/app.js b/app.js index b9945f6..a0a2405 100644 --- a/app.js +++ b/app.js @@ -76,7 +76,7 @@ const createWorker = async () => { }); return worker; } catch (error) { - console.log(`ERROR | createWorker | ${error.message}`); + console.error(`[createWorker] | ERROR | error: ${error.message}`); } }; @@ -152,7 +152,7 @@ const closeCall = (callId) => { console.log(`The call with id ${callId} has already been deleted`); } } catch (error) { - console.log(`ERROR | closeCall | callid ${callId} | ${error.message}`); + console.log(`[closeCall] | ERROR | callid: ${callId} | error: ${error.message}`); } }; @@ -204,7 +204,7 @@ peers.on('connection', async (socket) => { console.log(`[createRoom] missing callId ${callId}`); } } catch (error) { - console.log(`ERROR | createRoom | callId ${callId} | ${error.message}`); + console.error(`[createRoom] | ERROR | callId ${callId} | error: ${error.message}`); } finally { callback(callbackResponse); } @@ -239,9 +239,7 @@ peers.on('connection', async (socket) => { } } } catch (error) { - console.log( - `ERROR | createWebRtcTransport | callId ${socketDetails[socket.id]} | sender ${sender} | ${error.message}` - ); + console.error(`[createWebRtcTransport] | ERROR | callId: ${socketDetails[socket.id]} | sender: ${sender} | error: ${error.message}`); callback(error); } }); @@ -261,7 +259,7 @@ peers.on('connection', async (socket) => { ? await videoCalls[callId].initiatorProducerTransport.connect({ dtlsParameters }) : await videoCalls[callId].receiverProducerTransport.connect({ dtlsParameters }); } catch (error) { - console.log(`ERROR | transport-connect | callId ${socketDetails[socket.id]} | ${error.message}`); + console.error(`[transport-connect] | ERROR | callId: ${socketDetails[socket.id]} | error: ${error.message}`); } }); @@ -390,7 +388,7 @@ peers.on('connection', async (socket) => { // kind - producer type: audio/video socketToEmit?.emit('new-producer', { callId, kind }); } catch (error) { - console.log(`ERROR | transport-produce | callId ${socketDetails[socket.id]} | ${error.message}`); + console.error(`[transport-produce] | ERROR | callId: ${socketDetails[socket.id]} | error: ${error.message}`); } }); @@ -410,7 +408,7 @@ peers.on('connection', async (socket) => { await videoCalls[callId].initiatorConsumerTransport.connect({ dtlsParameters }); } } catch (error) { - console.log(`ERROR | transport-recv-connect | callId ${socketDetails[socket.id]} | ${error.message}`); + console.error(`[transport-recv-connect] | ERROR | callId: ${socketDetails[socket.id]} | error: ${error.message}`); } }); @@ -458,7 +456,7 @@ peers.on('connection', async (socket) => { }); } } catch (error) { - console.error(`[consume] ERROR | callId: ${callId} | error: ${error.message}`) + console.error(`[consume] | ERROR | callId: ${callId} | error: ${error.message}`) } console.log(`[consume] socket ${socket.id} | callId: ${callId} | canConsumeVideo: ${canConsumeVideo} | canConsumeAudio: ${canConsumeAudio}`); @@ -479,7 +477,7 @@ peers.on('connection', async (socket) => { callback(null); } } catch (error) { - console.error(`[consume] ERROR | callId: ${socketDetails[socket.id]} | error: ${error.message}`); + console.error(`[consume] | ERROR | callId: ${socketDetails[socket.id]} | error: ${error.message}`); callback({ params: { error } }); } }); @@ -504,7 +502,7 @@ peers.on('connection', async (socket) => { videoCalls[callId]?.receiverConsumerAudio?.resume(); } } catch (error) { - console.error(`[consumer-resume] | ERROR | callId: ${callId} | isInitiator: ${isInitiator} | error: ${error.message}`); + console.error(`[consumer-resume] | ERROR | callId: ${socketDetails[socket.id]} | isInitiator: ${isInitiator} | error: ${error.message}`); } }); @@ -519,7 +517,7 @@ peers.on('connection', async (socket) => { else if (kind === 'audio') videoCalls[callId].receiverAudioProducer.close() } } catch (error) { - console.log(`ERROR | consumer-resume | callId ${socketDetails[socket.id]} | ${error.message}`); + console.error(`ERROR | consumer-resume | callId ${socketDetails[socket.id]} | error: ${error.message}`); } }); @@ -679,7 +677,7 @@ const createWebRtcTransportLayer = async (callId, callback) => { // Set transport to producerTransport or consumerTransport return transport; } catch (error) { - console.log(`ERROR | createWebRtcTransportLayer | callId ${socketDetails[socket.id]} | ${error.message}`); + console.error(`[createWebRtcTransportLayer] | ERROR | callId: ${socketDetails[socket.id]} | error: ${error.message}`); callback({ params: { error } }); } };