LINXD-2209: Check queue length

This commit is contained in:
Sergiu Toma 2022-09-13 20:09:25 +03:00
parent b834016dcb
commit 782b749ea3
2 changed files with 8 additions and 6 deletions

2
.env
View File

@ -1,3 +1,3 @@
PORT=3000 PORT=3001
IP=0.0.0.0 # Listening IPv4 or IPv6. 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). ANNOUNCED_IP=185.8.154.190 # Announced IPv4 or IPv6 (useful when running mediasoup behind NAT with private IP).

12
app.js
View File

@ -118,11 +118,13 @@ const mediaCodecs = [
} }
setInterval(async () => { setInterval(async () => {
const { callId, callback } = queue.shift(); if (queue.length > 0) {
if (router[callId] === undefined) { const { callId, callback } = queue.shift();
router[callId] = await worker.createRouter({ mediaCodecs }) if (router[callId] === undefined) {
console.log(`[createRoom] Router ID: ${router[callId].id}`) router[callId] = await worker.createRouter({ mediaCodecs })
getRtpCapabilities(callId, callback) console.log(`[createRoom] Router ID: ${router[callId].id}`)
getRtpCapabilities(callId, callback)
}
} }
}, 2000); }, 2000);