Compare commits

...

2 Commits

Author SHA1 Message Date
3f3048e54f Refactor transportclose 8 2022-08-11 13:17:44 +03:00
ac5d5d7fd0 Refactor transportclose 7 2022-08-11 13:15:23 +03:00
2 changed files with 19 additions and 32 deletions

17
app.js
View File

@ -156,14 +156,9 @@ peers.on('connection', async socket => {
console.log(`[transport-produce] Producer ID: ${producer.id} | kind: ${producer.kind}`)
producer.on('transportclose', ({ callId }) => {
console.log('transport for this producer closed', callId)
closeRoom(callId);
})
producer.on('transportclose', () => {
console.log('transport2 for this producer closed', callId)
closeRoom(callId);
console.log('transport for this producer closed ')
producer.close()
})
// Send back to the client the Producer's id
@ -192,14 +187,8 @@ peers.on('connection', async socket => {
paused: true,
})
consumer.on('transportclose', ({ callId }) => {
console.log('transport close from consumer', callId)
closeRoom(callId);
})
consumer.on('transportclose', () => {
console.log('transport2 close from consumer', callId)
closeRoom(callId);
console.log('transport close from consumer')
})
consumer.on('producerclose', () => {

View File

@ -350,8 +350,6 @@ const createRecvTransport = async () => {
}
const resetCallSettings = () => {
console.log('resetCallSettings', callId, 'socket |', socket);
socket.emit('transportclose')
localVideo.srcObject = null
remoteVideo.srcObject = null
consumer = null
@ -398,24 +396,24 @@ const connectRecvTransport = async () => {
}
const closeCall = () => {
console.log('closeCall', callId);
// socket.emit('transportclose')
// Reset settings and send closeTransport to video server
resetCallSettings()
console.log('closeCall');
// // Emit 'notify-end' to Hub so the consumer will know to close the video
// const notifyEnd = {
// origin_asset_id: ASSET_ID,
// dest_asset_id: originAssetId || parseInt(urlParams.get('dest_asset_id')),
// type: 'notify-end',
// video_call_id: callId
// }
// console.log('notifyEnd', notifyEnd)
// hub.emit('video', JSON.stringify(notifyEnd))
// Emit 'notify-end' to Hub so the consumer will know to close the video
const notifyEnd = {
origin_asset_id: ASSET_ID,
dest_asset_id: originAssetId || parseInt(urlParams.get('dest_asset_id')),
type: 'notify-end',
video_call_id: callId
}
console.log('notifyEnd', notifyEnd)
hub.emit('video', JSON.stringify(notifyEnd))
// // Disable Close call button
// const closeCallBtn = document.getElementById('btnCloseCall')
// closeCallBtn.setAttribute('disabled', '')
// Disable Close call button
const closeCallBtn = document.getElementById('btnCloseCall')
closeCallBtn.setAttribute('disabled', '')
// Reset settings
resetCallSettings()
}
btnLocalVideo.addEventListener('click', getLocalStream)