Close producer when dispatcher close the window

This commit is contained in:
Sergiu Toma 2022-08-02 19:50:04 +03:00
parent 1ab77c1f17
commit b947318142

View File

@ -15,7 +15,12 @@ hub = io(config.hubAddress)
const connectToMediasoup = () => { const connectToMediasoup = () => {
socket = io(config.mediasoupAddress) socket = io(config.mediasoupAddress, {
reconnection: true,
reconnectionDelay: 1000,
reconnectionDelayMax : 5000,
reconnectionAttempts: Infinity
})
socket.on('connection-success', ({ _socketId, existsProducer }) => { socket.on('connection-success', ({ _socketId, existsProducer }) => {
console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`) console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`)
@ -63,6 +68,10 @@ if (IS_PRODUCER === true) {
socket.emit('transportclose') socket.emit('transportclose')
consumer = null consumer = null
producer = null producer = null
producerTransport = null
consumerTransport = null
device = null
socket.destroy()
} }
}) })
}) })