This commit is contained in:
Sergiu Toma 2023-01-13 19:59:12 +02:00
parent 91b21f862c
commit af85026bd2

102
app.js
View File

@ -260,8 +260,32 @@ peers.on('connection', async socket => {
console.log(`[transport-connect] socket ${socket.id} | callId ${callId}`); console.log(`[transport-connect] socket ${socket.id} | callId ${callId}`);
if (!isInitiator(callId, socket.id)) { if (!isInitiator(callId, socket.id)) {
await videoCalls[callId].receiverProducerTransport.connect({ dtlsParameters }); await videoCalls[callId].receiverProducerTransport.connect({ dtlsParameters });
// if (!isInitiator(callId, socket.id)) {
console.log('🟥 Emit to initiatorSocket');
videoCalls[callId].initiatorSocket.emit('new-producer', {
callId
});
// } else {
// console.log('🟥 Emit to receiverSocket');
// videoCalls[callId].receiverSocket.emit('new-producer', {
// callId
// });
// }
} else { } else {
await videoCalls[callId].initiatorProducerTransport.connect({ dtlsParameters }); await videoCalls[callId].initiatorProducerTransport.connect({ dtlsParameters });
// if (!isInitiator(callId, socket.id)) {
// console.log('🟥 Emit to initiatorSocket');
// videoCalls[callId].initiatorSocket.emit('new-producer', {
// callId
// });
// } else {
console.log('🟥 Emit to receiverSocket');
videoCalls[callId].receiverSocket.emit('new-producer', {
callId
});
// }
} }
} 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.message}`);
@ -290,54 +314,54 @@ peers.on('connection', async socket => {
try { // try {
const router = videoCalls[callId].router; // const router = videoCalls[callId].router;
router.observer.on("newtransport", (transport) => { // router.observer.on("newtransport", (transport) => {
transport.observer.on("newproducer", (producer) => { // transport.observer.on("newproducer", (producer) => {
console.log( // console.log(
"new producer created [worker.pid:%d, router.id:%s, transport.id:%s, producer.id:%s]", // "new producer created [worker.pid:%d, router.id:%s, transport.id:%s, producer.id:%s]",
worker.pid, router.id, transport.id, producer.id // worker.pid, router.id, transport.id, producer.id
); // );
// if (!isInitiator(callId, socket.id)) { // // if (!isInitiator(callId, socket.id)) {
// console.log('🟥 Emit to initiatorSocket'); // // console.log('🟥 Emit to initiatorSocket');
// videoCalls[callId].initiatorSocket.emit('new-producer', { // // videoCalls[callId].initiatorSocket.emit('new-producer', {
// callId // // callId
// }); // // });
// } else { // // } else {
// console.log('🟥 Emit to receiverSocket'); // // console.log('🟥 Emit to receiverSocket');
// videoCalls[callId].receiverSocket.emit('new-producer', { // // videoCalls[callId].receiverSocket.emit('new-producer', {
// callId // // callId
// }); // // });
// } // // }
console.log('$$$$ isInitiator(callId, socket.id)', isInitiator(callId, socket.id)); // console.log('$$$$ isInitiator(callId, socket.id)', isInitiator(callId, socket.id));
console.log('socket.id', socket.id); // console.log('socket.id', socket.id);
console.log('videoCalls', videoCalls); // console.log('videoCalls', videoCalls);
videoCalls[callId].receiverSocket.emit('new-producer', { // videoCalls[callId].receiverSocket.emit('new-producer', {
callId // callId
}); // });
// videoCalls[callId].initiatorSocket.emit('new-producer', { // // videoCalls[callId].initiatorSocket.emit('new-producer', {
// callId // // callId
// }); // // });
// videoCalls[callId].receiverSocket.emit('new-producer', { // // videoCalls[callId].receiverSocket.emit('new-producer', {
// callId // // callId
// }); // // });
// socket.emit('new-producer', { // // socket.emit('new-producer', {
// callId // // callId
// }); // // });
}); // });
}); // });
} catch (error) { // } catch (error) {
console.log('&&&&&&&&&&&&&&&&', error.message); // console.log('&&&&&&&&&&&&&&&&', error.message);
} // }