1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-27 06:23:53 +01:00

Merge branch 'main' into main

This commit is contained in:
Adam Wisher
2025-09-02 09:27:54 +01:00
committed by GitHub
15 changed files with 803 additions and 385 deletions

View File

@@ -6,6 +6,7 @@ var parsedData, signalChart, previousFreq;
var data = [];
var signalData = [];
let updateCounter = 0;
let lastReconnectAttempt = 0;
let messageCounter = 0; // Count for WebSocket data length returning 0
let messageData = 800; // Initial value anything above 0
let messageLength = 800; // Retain value of messageData until value is updated
@@ -375,10 +376,16 @@ function sendPingRequest() {
messageCounter = 0;
}
// Automatic reconnection on WebSocket close
if (socket.readyState === WebSocket.CLOSED || socket.readyState === WebSocket.CLOSING) {
// Automatic reconnection on WebSocket close with cooldown
const now = Date.now();
if (
(socket.readyState === WebSocket.CLOSED || socket.readyState === WebSocket.CLOSING) &&
(now - lastReconnectAttempt > TIMEOUT_DURATION)
) {
lastReconnectAttempt = now;
socket = new WebSocket(socketAddress);
socket.onopen = () => {
sendToast('info', 'Connected', 'Reconnected successfully!', false, false);
};