Close producer when dispatcher close the window

This commit is contained in:
Sergiu Toma 2022-08-02 19:33:39 +03:00
parent ea8d4268ec
commit 14d96fa7c5
2 changed files with 5 additions and 3 deletions

3
app.js
View File

@ -156,9 +156,10 @@ peers.on('connection', async socket => {
console.log(`[transport-produce] Producer ID: ${producer.id} | kind: ${producer.kind}`) console.log(`[transport-produce] Producer ID: ${producer.id} | kind: ${producer.kind}`)
producer.on('transportclose', () => { producer.on('transportclose', ({ callId }) => {
console.log('transport for this producer closed ') console.log('transport for this producer closed ')
producer.close() producer.close()
router[callId] = null
}) })
// Send back to the client the Producer's id // Send back to the client the Producer's id

View File

@ -56,7 +56,8 @@ if (IS_PRODUCER === true) {
} }
if (parsedData.type === 'notify-end') { if (parsedData.type === 'notify-end') {
remoteVideo.srcObject = null; localVideo.srcObject = null
remoteVideo.srcObject = null
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')
@ -271,7 +272,7 @@ const connectSendTransport = async () => {
// close video track // close video track
}) })
producer.on('transportclose', () => { producer.on('transportclose', { callId },() => {
console.log('transport ended') console.log('transport ended')
// close video track // close video track
}) })