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