Refactor transportclose 17

This commit is contained in:
Sergiu Toma 2022-08-11 22:24:33 +03:00
parent 3473c10608
commit 7a564d4a61

24
app.js
View File

@ -159,8 +159,11 @@ peers.on('connection', async socket => {
producer.on('transportclose', () => { producer.on('transportclose', () => {
console.log('transport for this producer closed', callId) console.log('transport for this producer closed', callId)
// closeRoom(callId)
// https://mediasoup.org/documentation/v3/mediasoup/api/#producer-close
producer.close() producer.close()
// https://mediasoup.org/documentation/v3/mediasoup/api/#router-close
router[callId].close() router[callId].close()
delete router[callId] delete router[callId]
}) })
@ -199,6 +202,8 @@ peers.on('connection', async socket => {
consumer.on('producerclose', () => { consumer.on('producerclose', () => {
console.log('producer of consumer closed', callId) console.log('producer of consumer closed', callId)
// https://mediasoup.org/documentation/v3/mediasoup/api/#router-close
router[callId].close() router[callId].close()
delete router[callId] delete router[callId]
}) })
@ -281,20 +286,3 @@ const createWebRtcTransportLayer = async (callId, callback) => {
}) })
} }
} }
const closeRoom = (callId) => {
console.log('[closeRoom]', callId);
// Close transport for producer/consumer
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#Transport-methods
// producerTransport.close()
// consumerTransport.close()
// Close producer and consumer
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#producer-close
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#consumer-closed
producer.close()
consumer.close()
// Reset room
delete router[callId]
}