diff --git a/app.js b/app.js index e3a2600..640c56a 100644 --- a/app.js +++ b/app.js @@ -389,19 +389,32 @@ peers.on('connection', async (socket) => { try { const callId = socketDetails[socket.id]; const socketId = socket.id; + let audioParams, videoParams; - console.log(`[consume] socket ${socket.id} | callId: ${callId}`); + console.log(`[consume] socket ${socketId} | callId: ${callId}`); if (typeof rtpCapabilities === 'string') rtpCapabilities = JSON.parse(rtpCapabilities); - - callback({ - videoParams: await consumeVideo({ callId, socketId, rtpCapabilities }), - audioParams: await consumeAudio({ callId, socketId, rtpCapabilities }), - }); } catch (error) { - console.error(`[consume] | ERROR | callId: ${socketDetails[socket.id]} | error: ${error.message}`); + console.error(`[consume] | ERROR | callId: ${callId} | error: ${error.message}`); callback({ params: { error } }); } + + try { + videoParams = await consumeVideo({ callId, socketId, rtpCapabilities }); + } catch (error) { + console.error(`[consume] | ERROR | videoParams | callId: ${callId} | error: ${error.message}`); + } + + try { + audioParams = await consumeAudio({ callId, socketId, rtpCapabilities }); + } catch (error) { + console.error(`[consume] | ERROR | audioParams | callId: ${callId} | error: ${error.message}`); + } + + callback({ + videoParams, + audioParams, + }); }); /*