Skip to content

Commit 285e837

Browse files
author
Yuqi Huang
committed
Add periodic logging for WebRTC ingestion mode
1 parent 283bdef commit 285e837

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

examples/master.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,10 @@ registerMasterSignalingClientCallbacks = (signalingClient, formValues, onStatsRe
228228
// If in WebRTC ingestion mode, retry if no connection was established within 30 seconds.
229229
// Note: This is an interim setting - the viewer application will retry after 30 seconds if the connection through the WebRTC Ingestion mode is not successful.
230230
if (master.channelHelper.isIngestionEnabled()) {
231-
for (let i = 5; i <= 30; i += 5) {
231+
const CHECK_INTERVAL_SECONDS = 5;
232+
const RETRY_TIMEOUT_SECONDS = 30;
233+
234+
for (let i = CHECK_INTERVAL_SECONDS; i <= RETRY_TIMEOUT_SECONDS; i += CHECK_INTERVAL_SECONDS) {
232235
setTimeout(function () {
233236
// check the state each 5 seconds
234237
//enter retry if still connecting after 30 seconds
@@ -237,14 +240,14 @@ registerMasterSignalingClientCallbacks = (signalingClient, formValues, onStatsRe
237240
answerer.getPeerConnection().connectionState !== 'failed' &&
238241
answerer.getPeerConnection().connectionState !== 'closed'
239242
) {
240-
if (i < 30) {
243+
if (i < RETRY_TIMEOUT_SECONDS) {
241244
console.log(`[${role}] Still connecting after ${i} seconds.`);
242245
} else {
243-
console.error(`[${role}] Connection was not successful - Will retry after 30 seconds.`);
246+
console.error(`[${role}] Connection was not successful - Will retry after ${RETRY_TIMEOUT_SECONDS} seconds.`);
244247
onPeerConnectionFailed(remoteClientId, false, false);
245248
}
246249
}
247-
}, i* 1000);
250+
}, i * 1000);
248251
}
249252
}
250253
});

0 commit comments

Comments
 (0)