Compare commits

..

10 Commits

16
app.js
View File

@ -204,7 +204,7 @@ peers.on('connection', async socket => {
} }
} }
} catch (error) { } catch (error) {
console.log(`ERROR | createWebRtcTransport | callId ${callId} | sender ${sender} | ${error.message}`); console.log(`ERROR | createWebRtcTransport | callId ${socketDetails[socket.id]} | sender ${sender} | ${error.message}`);
} }
}); });
@ -215,10 +215,12 @@ peers.on('connection', async socket => {
socket.on('transport-connect', async ({ dtlsParameters }) => { socket.on('transport-connect', async ({ dtlsParameters }) => {
try { try {
const callId = socketDetails[socket.id]; const callId = socketDetails[socket.id];
console.log(`[transport-connect] socket.id ${socket.id} | callId ${callId}`) if (typeof dtlsParameters === 'string') dtlsParameters = JSON.parse(dtlsParameters);
console.log(`[transport-connect] socket.id ${socket.id} | callId ${callId}`);
await videoCalls[callId].producerTransport.connect({ dtlsParameters }); await videoCalls[callId].producerTransport.connect({ dtlsParameters });
} catch (error) { } catch (error) {
console.log(`ERROR | transport-connect | callId ${socketDetails[socket.id]} | ${error.message}`); console.log(`ERROR | transport-connect | callId ${socketDetails[socket.id]} | ${error.stack}`);
} }
}); });
@ -230,6 +232,9 @@ peers.on('connection', async socket => {
socket.on('transport-produce', async ({ kind, rtpParameters, appData }) => { socket.on('transport-produce', async ({ kind, rtpParameters, appData }) => {
try { try {
const callId = socketDetails[socket.id]; const callId = socketDetails[socket.id];
if (typeof kind === 'string') kind = JSON.parse(kind);
if (typeof rtpParameters === 'string') rtpParameters = JSON.parse(rtpParameters);
console.log('[transport-produce] | socket.id', socket.id, '| callId', callId); console.log('[transport-produce] | socket.id', socket.id, '| callId', callId);
videoCalls[callId].producer = await videoCalls[callId].producerTransport.produce({ videoCalls[callId].producer = await videoCalls[callId].producerTransport.produce({
kind, kind,
@ -314,7 +319,7 @@ peers.on('connection', async socket => {
console.log(`[canConsume] Can't consume | callId ${callId}`); console.log(`[canConsume] Can't consume | callId ${callId}`);
} }
} catch (error) { } catch (error) {
console.log(`ERROR | consume | callId ${callId} | ${error.message}`) console.log(`ERROR | consume | callId ${socketDetails[socket.id]} | ${error.message}`)
callback({ params: { error } }); callback({ params: { error } });
} }
}); });
@ -381,6 +386,7 @@ const createWebRtcTransportLayer = async (callId, callback) => {
dtlsParameters: transport.dtlsParameters, dtlsParameters: transport.dtlsParameters,
}; };
console.log(`createWebRtcTransportLayer | params.dtlsParameters ${params.dtlsParameters}`);
// Send back to the client the params // Send back to the client the params
callback({ params }); callback({ params });
@ -388,7 +394,7 @@ const createWebRtcTransportLayer = async (callId, callback) => {
return transport; return transport;
} catch (error) { } catch (error) {
console.log(`ERROR | createWebRtcTransportLayer | callId ${callId} | ${error.message}`); console.log(`ERROR | createWebRtcTransportLayer | callId ${socketDetails[socket.id]} | ${error.message}`);
callback({ params: { error } }); callback({ params: { error } });
} }
} }