Close producer when dispatcher close the window

This commit is contained in:
Sergiu Toma 2022-08-02 19:43:08 +03:00
parent 14d96fa7c5
commit 1ab77c1f17
2 changed files with 6 additions and 1 deletions

3
app.js
View File

@ -190,6 +190,9 @@ peers.on('connection', async socket => {
consumer.on('transportclose', () => { consumer.on('transportclose', () => {
console.log('transport close from consumer') console.log('transport close from consumer')
producer.close()
consumer.close()
router[callId] = null
}) })
consumer.on('producerclose', () => { consumer.on('producerclose', () => {

View File

@ -61,6 +61,8 @@ if (IS_PRODUCER === true) {
console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId);
// socket.emit('transportclose') // socket.emit('transportclose')
socket.emit('transportclose') socket.emit('transportclose')
consumer = null
producer = null
} }
}) })
}) })
@ -272,7 +274,7 @@ const connectSendTransport = async () => {
// close video track // close video track
}) })
producer.on('transportclose', { callId },() => { producer.on('transportclose', () => {
console.log('transport ended') console.log('transport ended')
// close video track // close video track
}) })