From 782b749ea38c7af2c61b6bdcb736320eca292ed1 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Tue, 13 Sep 2022 20:09:25 +0300 Subject: [PATCH] LINXD-2209: Check queue length --- .env | 2 +- app.js | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.env b/.env index 6d8b7b8..551a6ac 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ -PORT=3000 +PORT=3001 IP=0.0.0.0 # Listening IPv4 or IPv6. ANNOUNCED_IP=185.8.154.190 # Announced IPv4 or IPv6 (useful when running mediasoup behind NAT with private IP). diff --git a/app.js b/app.js index 3dbabbb..8ef4ba6 100644 --- a/app.js +++ b/app.js @@ -118,11 +118,13 @@ const mediaCodecs = [ } setInterval(async () => { - const { callId, callback } = queue.shift(); - if (router[callId] === undefined) { - router[callId] = await worker.createRouter({ mediaCodecs }) - console.log(`[createRoom] Router ID: ${router[callId].id}`) - getRtpCapabilities(callId, callback) + if (queue.length > 0) { + const { callId, callback } = queue.shift(); + if (router[callId] === undefined) { + router[callId] = await worker.createRouter({ mediaCodecs }) + console.log(`[createRoom] Router ID: ${router[callId].id}`) + getRtpCapabilities(callId, callback) + } } }, 2000);