Set initiatorSocketId to be dispatcher

This commit is contained in:
Sergiu Toma 2022-12-13 13:04:43 +02:00
parent d633eec92f
commit 92fbecc36a

13
app.js
View File

@ -200,9 +200,9 @@ peers.on('connection', async socket => {
console.log('[createRoom] callId', callId);
videoCalls[callId] = { router: await worker.createRouter({ mediaCodecs }) }
console.log(`[createRoom] Router ID: ${videoCalls[callId].router.id}`);
videoCalls[callId].initiatorSockerId = socket.id
} else {
videoCalls[callId].receiverSocketId = socket.id
} else {
videoCalls[callId].initiatorSockerId = socket.id
}
socketDetails[socket.id] = callId;
// rtpCapabilities is set for callback
@ -453,6 +453,10 @@ const consumeAudio = async (callId, rtpCapabilities) => {
console.log('producer of consumer closed', callId);
closeCall(callId);
});
if(isInitiator(callId, sockId)) {
}
return {
id: videoCalls[callId].consumerAudio.id,
producerId: videoCalls[callId].producerAudio.id,
@ -461,9 +465,8 @@ const consumeAudio = async (callId, rtpCapabilities) => {
}
}
const isInitiator = async (callId, socketId) => {
if (videoCalls[callId].initiatorSockerId === socketId) return true;
else return false
const isInitiator = (callId, socketId) => {
return (videoCalls[callId].initiatorSockerId === socketId);
}
/*