diff --git a/app.js b/app.js index 533110a..4275835 100644 --- a/app.js +++ b/app.js @@ -225,7 +225,7 @@ peers.on('connection', async socket => { */ socket.on('createWebRtcTransport', async ({ sender }, callback) => { try { - console.log('🟥', JSON.stringify(sender), socket.id); + console.log('🟥', socket.id, JSON.stringify(sender)); const callId = socketDetails[socket.id]; console.log(`[createWebRtcTransport] socket ${socket.id} | sender ${sender} | callId ${callId}`); if (sender) { diff --git a/public/bundle.js b/public/bundle.js index a6eb0ec..62f84c4 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20811,8 +20811,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) + } + }) + + connectRecvTransport() + }) +} btnLocalVideo.addEventListener('click', getLocalStream) -btnRecvSendTransport.addEventListener('click', goConnect) +btnRecvSendTransport.addEventListener('click', consume) btnCloseCall.addEventListener('click', closeCall) },{"./config":94,"mediasoup-client":66,"socket.io-client":82}]},{},[95]); diff --git a/public/index.js b/public/index.js index 9233a51..4d3a530 100644 --- a/public/index.js +++ b/public/index.js @@ -453,7 +453,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) + } + }) + + connectRecvTransport() + }) +} btnLocalVideo.addEventListener('click', getLocalStream) -btnRecvSendTransport.addEventListener('click', goConnect) +btnRecvSendTransport.addEventListener('click', consume) btnCloseCall.addEventListener('click', closeCall) \ No newline at end of file