Spaces:
Sleeping
Sleeping
disable queue checker when stream is active
Browse files
frontend/src/routes/+page.svelte
CHANGED
@@ -17,6 +17,8 @@
|
|
17 |
let isImageMode: boolean = false;
|
18 |
let maxQueueSize: number = 0;
|
19 |
let currentQueueSize: number = 0;
|
|
|
|
|
20 |
onMount(() => {
|
21 |
getSettings();
|
22 |
});
|
@@ -29,16 +31,21 @@
|
|
29 |
maxQueueSize = settings.max_queue_size;
|
30 |
pageContent = settings.page_content;
|
31 |
console.log(pipelineParams);
|
32 |
-
|
|
|
|
|
|
|
|
|
33 |
getQueueSize();
|
34 |
-
setInterval(() => {
|
35 |
-
getQueueSize();
|
36 |
-
}, 2000);
|
37 |
}
|
38 |
}
|
39 |
async function getQueueSize() {
|
|
|
|
|
|
|
40 |
const data = await fetch('/queue_size').then((r) => r.json());
|
41 |
currentQueueSize = data.queue_size;
|
|
|
42 |
}
|
43 |
|
44 |
function getSreamdata() {
|
@@ -61,11 +68,13 @@
|
|
61 |
disabled = true;
|
62 |
await lcmLiveActions.start(getSreamdata);
|
63 |
disabled = false;
|
|
|
64 |
} else {
|
65 |
if (isImageMode) {
|
66 |
mediaStreamActions.stop();
|
67 |
}
|
68 |
lcmLiveActions.stop();
|
|
|
69 |
}
|
70 |
}
|
71 |
</script>
|
|
|
17 |
let isImageMode: boolean = false;
|
18 |
let maxQueueSize: number = 0;
|
19 |
let currentQueueSize: number = 0;
|
20 |
+
let queueCheckerRunning: boolean = false;
|
21 |
+
|
22 |
onMount(() => {
|
23 |
getSettings();
|
24 |
});
|
|
|
31 |
maxQueueSize = settings.max_queue_size;
|
32 |
pageContent = settings.page_content;
|
33 |
console.log(pipelineParams);
|
34 |
+
toggleQueueChecker(true);
|
35 |
+
}
|
36 |
+
function toggleQueueChecker(start: boolean) {
|
37 |
+
queueCheckerRunning = start && maxQueueSize > 0;
|
38 |
+
if (start) {
|
39 |
getQueueSize();
|
|
|
|
|
|
|
40 |
}
|
41 |
}
|
42 |
async function getQueueSize() {
|
43 |
+
if (!queueCheckerRunning) {
|
44 |
+
return;
|
45 |
+
}
|
46 |
const data = await fetch('/queue_size').then((r) => r.json());
|
47 |
currentQueueSize = data.queue_size;
|
48 |
+
setTimeout(getQueueSize, 1000);
|
49 |
}
|
50 |
|
51 |
function getSreamdata() {
|
|
|
68 |
disabled = true;
|
69 |
await lcmLiveActions.start(getSreamdata);
|
70 |
disabled = false;
|
71 |
+
toggleQueueChecker(false);
|
72 |
} else {
|
73 |
if (isImageMode) {
|
74 |
mediaStreamActions.stop();
|
75 |
}
|
76 |
lcmLiveActions.stop();
|
77 |
+
toggleQueueChecker(true);
|
78 |
}
|
79 |
}
|
80 |
</script>
|