diff --git a/app.js b/app.js index 5359aa8..7e97cec 100644 --- a/app.js +++ b/app.js @@ -260,7 +260,6 @@ peers.on('connection', async (socket) => { isInitiator(callId, socket.id) ? await videoCalls[callId].initiatorProducerTransport.connect({ dtlsParameters }) : await videoCalls[callId].receiverProducerTransport.connect({ dtlsParameters }); - } catch (error) { console.log(`ERROR | transport-connect | callId ${socketDetails[socket.id]} | ${error.message}`); } @@ -370,8 +369,10 @@ peers.on('connection', async (socket) => { const socketToEmit = isInitiator(callId, socket.id) ? videoCalls[callId].receiverSocket : videoCalls[callId].initiatorSocket; - socketToEmit.emit('new-producer', { callId }); + // callId - Id of the call + // kind - producer type: audio/video + socketToEmit.emit('new-producer', { callId, kind }); } catch (error) { console.log(`ERROR | transport-produce | callId ${socketDetails[socket.id]} | ${error.message}`); } diff --git a/public/bundle.js b/public/bundle.js index 85de9b9..ee7b33e 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20353,7 +20353,7 @@ module.exports = yeast; },{}],94:[function(require,module,exports){ module.exports = { hubAddress: 'https://hub.dev.linx.safemobile.com/', - mediasoupAddress: 'https://video.safemobile.org', + mediasoupAddress: 'https://video.safemobile.org/', } },{}],95:[function(require,module,exports){ const io = require('socket.io-client') @@ -20453,9 +20453,9 @@ setTimeout(() => { if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() } }) - socket.on('new-producer', ({ callId }) => { - console.log(`🟢 new-producer | callId: ${callId} | Ready to consume`); - consume() + socket.on('new-producer', ({ callId, kind }) => { + console.log(`🟢 new-producer | callId: ${callId} | kind: ${kind} | Ready to consume`); + connectRecvTransport(); }) } @@ -20735,6 +20735,8 @@ const connectSendTransport = async () => { // Enable Close call button const closeCallBtn = document.getElementById('btnCloseCall'); closeCallBtn.removeAttribute('disabled'); + + createRecvTransport(); } const createRecvTransport = async () => { @@ -20774,7 +20776,8 @@ const createRecvTransport = async () => { errback(error) } }) - connectRecvTransport() + // We call it in new-rpoducer, we don't need it here anymore + // connectRecvTransport() }) } @@ -20907,31 +20910,31 @@ const closeCall = () => { resetCallSettings() } -const consume = async () => { - console.log('[consume]') - console.log('createRecvTransport Consumer') - await socket.emit('createWebRtcTransport', { sender: false, callId, dispatcher: true }, ({ params }) => { - if (params.error) { - console.log('createRecvTransport | createWebRtcTransport | Error', params.error) - return - } - consumerTransport = device.createRecvTransport(params) - consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => { - try { - await socket.emit('transport-recv-connect', { - dtlsParameters, - }) - callback() - } catch (error) { - errback(error) - } - }) +// const consume = async (kind) => { +// console.log(`[consume] kind: ${kind}`) +// console.log('createRecvTransport Consumer') +// await socket.emit('createWebRtcTransport', { sender: false, callId, dispatcher: true }, ({ params }) => { +// if (params.error) { +// console.log('createRecvTransport | createWebRtcTransport | Error', params.error) +// return +// } +// consumerTransport = device.createRecvTransport(params) +// consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => { +// try { +// await socket.emit('transport-recv-connect', { +// dtlsParameters, +// }) +// callback() +// } catch (error) { +// errback(error) +// } +// }) - connectRecvTransport() - }) -} +// connectRecvTransport() +// }) +// } btnLocalVideo.addEventListener('click', getLocalStream) -btnRecvSendTransport.addEventListener('click', consume) +// btnRecvSendTransport.addEventListener('click', consume) btnCloseCall.addEventListener('click', closeCall) },{"./config":94,"mediasoup-client":66,"socket.io-client":82}]},{},[95]); diff --git a/public/config.js b/public/config.js index fa3612f..4d1b6a4 100644 --- a/public/config.js +++ b/public/config.js @@ -1,4 +1,4 @@ module.exports = { hubAddress: 'https://hub.dev.linx.safemobile.com/', - mediasoupAddress: 'https://video.safemobile.org', + mediasoupAddress: 'https://video.safemobile.org/', } \ No newline at end of file diff --git a/public/index.html b/public/index.html index a44cd99..d8ce60e 100644 --- a/public/index.html +++ b/public/index.html @@ -75,7 +75,7 @@
- +
diff --git a/public/index.js b/public/index.js index 1fbf13a..0fdb4f0 100644 --- a/public/index.js +++ b/public/index.js @@ -95,9 +95,9 @@ setTimeout(() => { if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() } }) - socket.on('new-producer', ({ callId }) => { - console.log(`🟢 new-producer | callId: ${callId} | Ready to consume`); - consume() + socket.on('new-producer', ({ callId, kind }) => { + console.log(`🟢 new-producer | callId: ${callId} | kind: ${kind} | Ready to consume`); + connectRecvTransport(); }) } @@ -377,6 +377,8 @@ const connectSendTransport = async () => { // Enable Close call button const closeCallBtn = document.getElementById('btnCloseCall'); closeCallBtn.removeAttribute('disabled'); + + createRecvTransport(); } const createRecvTransport = async () => { @@ -416,7 +418,8 @@ const createRecvTransport = async () => { errback(error) } }) - connectRecvTransport() + // We call it in new-rpoducer, we don't need it here anymore + // connectRecvTransport() }) } @@ -549,30 +552,30 @@ const closeCall = () => { resetCallSettings() } -const consume = async () => { - console.log('[consume]') - console.log('createRecvTransport Consumer') - await socket.emit('createWebRtcTransport', { sender: false, callId, dispatcher: true }, ({ params }) => { - if (params.error) { - console.log('createRecvTransport | createWebRtcTransport | Error', params.error) - return - } - consumerTransport = device.createRecvTransport(params) - consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => { - try { - await socket.emit('transport-recv-connect', { - dtlsParameters, - }) - callback() - } catch (error) { - errback(error) - } - }) +// const consume = async (kind) => { +// console.log(`[consume] kind: ${kind}`) +// console.log('createRecvTransport Consumer') +// await socket.emit('createWebRtcTransport', { sender: false, callId, dispatcher: true }, ({ params }) => { +// if (params.error) { +// console.log('createRecvTransport | createWebRtcTransport | Error', params.error) +// return +// } +// consumerTransport = device.createRecvTransport(params) +// consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => { +// try { +// await socket.emit('transport-recv-connect', { +// dtlsParameters, +// }) +// callback() +// } catch (error) { +// errback(error) +// } +// }) - connectRecvTransport() - }) -} +// connectRecvTransport() +// }) +// } btnLocalVideo.addEventListener('click', getLocalStream) -btnRecvSendTransport.addEventListener('click', consume) +// btnRecvSendTransport.addEventListener('click', consume) btnCloseCall.addEventListener('click', closeCall) \ No newline at end of file