LINXD-2197: On peer disconnect delete the call; Added log when call is already deleted; Added log when user send multiple createWebRtcTransport
This commit is contained in:
parent
eb5aa12d65
commit
b0fad5f1db
24
app.js
24
app.js
@ -116,6 +116,8 @@ const closeCall = (callId) => {
|
|||||||
videoCalls[callId]?.producerTransport.close();
|
videoCalls[callId]?.producerTransport.close();
|
||||||
videoCalls[callId].router.close();
|
videoCalls[callId].router.close();
|
||||||
delete videoCalls[callId];
|
delete videoCalls[callId];
|
||||||
|
} else {
|
||||||
|
console.log(`The call with id ${callId} has already been deleted`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(`ERROR | closeCall | callid ${callId} | ${error.message}`);
|
console.log(`ERROR | closeCall | callid ${callId} | ${error.message}`);
|
||||||
@ -146,8 +148,10 @@ peers.on('connection', async socket => {
|
|||||||
|
|
||||||
// It is triggered when the peer is disconnected
|
// It is triggered when the peer is disconnected
|
||||||
socket.on('disconnect', () => {
|
socket.on('disconnect', () => {
|
||||||
console.log('peer disconnected | socket.id', socket.id);
|
const callId = socketDetails[socket.id];
|
||||||
|
console.log(`disconnect | socket ${socket.id} | callId ${callId}`);
|
||||||
delete socketDetails[socket.id];
|
delete socketDetails[socket.id];
|
||||||
|
closeCall(callId);
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -186,10 +190,18 @@ peers.on('connection', async socket => {
|
|||||||
try {
|
try {
|
||||||
const callId = socketDetails[socket.id];
|
const callId = socketDetails[socket.id];
|
||||||
console.log(`[createWebRtcTransport] sender ${sender} | callId ${callId}`);
|
console.log(`[createWebRtcTransport] sender ${sender} | callId ${callId}`);
|
||||||
if (sender && !videoCalls[callId].producerTransport) {
|
if (sender) {
|
||||||
videoCalls[callId].producerTransport = await createWebRtcTransportLayer(callId, callback)
|
if (!videoCalls[callId].producerTransport) {
|
||||||
} else if (!sender && !videoCalls[callId].consumerTransport) {
|
videoCalls[callId].producerTransport = await createWebRtcTransportLayer(callId, callback);
|
||||||
videoCalls[callId].consumerTransport = await createWebRtcTransportLayer(callId, callback)
|
} else {
|
||||||
|
console.log(`producerTransport has already been defined | callId ${callId}`);
|
||||||
|
}
|
||||||
|
} else if (!sender) {
|
||||||
|
if (!videoCalls[callId].consumerTransport) {
|
||||||
|
videoCalls[callId].consumerTransport = await createWebRtcTransportLayer(callId, callback);
|
||||||
|
} else {
|
||||||
|
console.log(`consumerTransport has already been defined | callId ${callId}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(`ERROR | createWebRtcTransport | callId ${callId} | sender ${sender} | ${error.message}`);
|
console.log(`ERROR | createWebRtcTransport | callId ${callId} | sender ${sender} | ${error.message}`);
|
||||||
@ -245,7 +257,7 @@ peers.on('connection', async socket => {
|
|||||||
console.log(`[transport-recv-connect] socket.id ${socket.id} | callId ${callId}`);
|
console.log(`[transport-recv-connect] socket.id ${socket.id} | callId ${callId}`);
|
||||||
await videoCalls[callId].consumerTransport.connect({ dtlsParameters });
|
await videoCalls[callId].consumerTransport.connect({ dtlsParameters });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(`ERROR | transport-recv-connect | callId ${socketDetails[socket.id]} | ERROR`);
|
console.log(`ERROR | transport-recv-connect | callId ${socketDetails[socket.id]} | ${error.message}`);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user