From ea8d4268ec86378fb43645a52c3b67f36ba73ed6 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 2 Aug 2022 19:10:52 +0300 Subject: [PATCH] Close producer when dispatcher close the window --- public/config.js | 3 +-- public/index.js | 14 ++++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/public/config.js b/public/config.js index 2a1ddaf..d2e2d91 100644 --- a/public/config.js +++ b/public/config.js @@ -1,5 +1,4 @@ module.exports = { hubAddress: 'https://hub.dev.linx.safemobile.com/', mediasoupAddress: 'https://video.safemobile.org/mediasoup', -} - +} \ No newline at end of file diff --git a/public/index.js b/public/index.js index e56f28b..c30f4d1 100644 --- a/public/index.js +++ b/public/index.js @@ -43,17 +43,24 @@ if (IS_PRODUCER === true) { hub.on('video', (data) => { const parsedData = JSON.parse(data); + + if (parsedData.type === 'notify-request') { console.log('video', parsedData) originAssetId = parsedData.origin_asset_id; originAssetName = parsedData.origin_asset_name; originAssetTypeName = parsedData.origin_asset_type_name; callId = parsedData.video_call_id; - console.log('IS_PRODUCER', IS_PRODUCER, 'callId', callId); - - if (parsedData.type === 'notify-request' && IS_PRODUCER) { + console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); getLocalStream() } + + if (parsedData.type === 'notify-end') { + remoteVideo.srcObject = null; + console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + // socket.emit('transportclose') + socket.emit('transportclose') + } }) }) @@ -261,7 +268,6 @@ const connectSendTransport = async () => { producer.on('trackended', () => { console.log('track ended') - // close video track })