Compare commits

..

4 Commits

19
app.js
View File

@ -204,7 +204,7 @@ peers.on('connection', async socket => {
}
}
} 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,7 +215,9 @@ peers.on('connection', async socket => {
socket.on('transport-connect', async ({ dtlsParameters }) => {
try {
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 });
} catch (error) {
console.log(`ERROR | transport-connect | callId ${socketDetails[socket.id]} | ${error.message}`);
@ -227,9 +229,11 @@ peers.on('connection', async socket => {
- For the router with the id callId, we make produce on producerTransport
- Create the handler on producer at the 'transportclose' event
*/
socket.on('transport-produce', async ({ kind, rtpParameters, appData }) => {
socket.on('transport-produce', async ({ kind, rtpParameters, appData }, callback) => {
try {
const callId = socketDetails[socket.id];
if (typeof rtpParameters === 'string') rtpParameters = JSON.parse(rtpParameters);
console.log('[transport-produce] | socket.id', socket.id, '| callId', callId);
videoCalls[callId].producer = await videoCalls[callId].producerTransport.produce({
kind,
@ -242,6 +246,11 @@ peers.on('connection', async socket => {
console.log('transport for this producer closed', callId)
closeCall(callId);
});
// Send back to the client the Producer's id
// callback({
// id: videoCalls[callId].producer.id
// });
} catch (error) {
console.log(`ERROR | transport-produce | callId ${socketDetails[socket.id]} | ${error.message}`);
}
@ -314,7 +323,7 @@ peers.on('connection', async socket => {
console.log(`[canConsume] Can't consume | callId ${callId}`);
}
} catch (error) {
console.log(`ERROR | consume | callId ${callId} | ${error.message}`)
console.log(`ERROR | consume | callId ${socketDetails[socket.id]} | ${error.message}`)
callback({ params: { error } });
}
});
@ -388,7 +397,7 @@ const createWebRtcTransportLayer = async (callId, callback) => {
return transport;
} catch (error) {
console.log(`ERROR | createWebRtcTransportLayer | callId ${callId} | ${error.message}`);
console.log(`ERROR | createWebRtcTransportLayer | callId ${socketDetails[socket.id]} | ${error.message}`);
callback({ params: { error } });
}
}