LINXD-2209: Correctly set router to videoCalls

This commit is contained in:
Sergiu Toma 2022-09-15 09:39:52 +03:00
parent 434c8f744c
commit ead0069aa8

7
app.js
View File

@ -101,7 +101,7 @@ const mediaCodecs = [
const getRtpCapabilities = (callId, callback) => { const getRtpCapabilities = (callId, callback) => {
console.log('[getRtpCapabilities] callId', callId); console.log('[getRtpCapabilities] callId', callId);
const rtpCapabilities = videoCalls[callId] = { router: rtpCapabilities }; const rtpCapabilities = videoCalls[callId].router.rtpCapabilities;
callback({ rtpCapabilities }); callback({ rtpCapabilities });
} }
@ -118,11 +118,14 @@ peers.on('connection', async socket => {
}) })
socket.on('createRoom', async ({ callId }, callback) => { socket.on('createRoom', async ({ callId }, callback) => {
if (videoCalls[callId] && videoCalls[callId].router === undefined) { console.log('[createRoom] videoCalls', videoCalls);
if (!videoCalls[callId]) {
console.log('create room');
console.log('[createRoom] callId', callId); console.log('[createRoom] callId', callId);
videoCalls[callId].router = await worker.createRouter({ mediaCodecs }); videoCalls[callId].router = await worker.createRouter({ mediaCodecs });
console.log(`[createRoom] Router ID: ${videoCalls[callId].router.id}`) console.log(`[createRoom] Router ID: ${videoCalls[callId].router.id}`)
} }
console.log('room exists');
socketDetails[socket.id] = callId; socketDetails[socket.id] = callId;
getRtpCapabilities(callId, callback); getRtpCapabilities(callId, callback);
}) })