()
| 584 | }; |
| 585 | |
| 586 | const startSocket = () => { |
| 587 | if (ws || !isWindowVisible()) return; |
| 588 | |
| 589 | retryCount = 0; |
| 590 | lastFrameTime = Date.now(); |
| 591 | ws = createSocket(); |
| 592 | |
| 593 | stallCheckInterval = setInterval(() => { |
| 594 | if ( |
| 595 | ws?.readyState === WebSocket.OPEN && |
| 596 | isWindowVisible() && |
| 597 | lastFrameTime > 0 && |
| 598 | Date.now() - lastFrameTime > STALL_TIMEOUT_MS |
| 599 | ) { |
| 600 | lastFrameTime = Date.now(); |
| 601 | commands.refreshCameraFeed().catch(() => {}); |
| 602 | ws.close(); |
| 603 | } |
| 604 | }, STALL_TIMEOUT_MS); |
| 605 | }; |
| 606 | |
| 607 | createEffect(() => { |
| 608 | if (isWindowVisible()) { |
no test coverage detected