From eb5aa12d65724dfc798d70a5e8da58c4eaf73c63 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 27 Sep 2022 07:55:25 +0300 Subject: [PATCH] LINXD-2197: Added the initial demo project used; Check before set producerTransport and consumerTransport if it was set before --- README.md | 6 +++++- app.js | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8ca0eb7..55ecd20 100644 --- a/README.md +++ b/README.md @@ -32,4 +32,8 @@ accountId = account id of the unit on which you are doing the test producer = it will always be true because you are the producer (it's possible to put false, but then you have to have another client with producer true) assetName = asset name of the unit on which you are doing the test -assetType = asset type of the unit on which you are doing the test \ No newline at end of file +assetType = asset type of the unit on which you are doing the test + +### Demo project + The demo project used initially and then modified for our needs `https://github.com/jamalag/mediasoup2` + diff --git a/app.js b/app.js index eb2a16d..dfaf6f1 100644 --- a/app.js +++ b/app.js @@ -186,10 +186,10 @@ peers.on('connection', async socket => { try { const callId = socketDetails[socket.id]; console.log(`[createWebRtcTransport] sender ${sender} | callId ${callId}`); - if (sender) { - videoCalls[callId].producerTransport = await createWebRtcTransportLayer(callId, callback); - } else { - videoCalls[callId].consumerTransport = await createWebRtcTransportLayer(callId, callback); + if (sender && !videoCalls[callId].producerTransport) { + videoCalls[callId].producerTransport = await createWebRtcTransportLayer(callId, callback) + } else if (!sender && !videoCalls[callId].consumerTransport) { + videoCalls[callId].consumerTransport = await createWebRtcTransportLayer(callId, callback) } } catch (error) { console.log(`ERROR | createWebRtcTransport | callId ${callId} | sender ${sender} | ${error.message}`);