Letzte Station bekommt prio

This commit is contained in:
2026-03-11 15:22:51 +01:00
parent 080a264271
commit 3b20247edd
2 changed files with 55 additions and 15 deletions

View File

@@ -6,6 +6,7 @@ const ctx = canvas.getContext('2d');
let isDrawing = false;
let hasSignature = false;
let ws = null;
let shouldReconnect = true;
let currentPdf = null;
let pdfDoc = null;
let currentPageNum = 1;
@@ -45,6 +46,26 @@ function connectWebSocket() {
if (warning) {
warning.style.display = 'block';
}
} else if (data.type === 'replaced_by_new_station') {
console.log('⚠️ Diese Signatur-Station wurde durch eine neuere Verbindung ersetzt');
// Zeige eine deutliche Meldung an dieser Station
const warning = document.getElementById('alreadyConnectedWarning');
if (warning) {
warning.textContent = currentLanguage === 'de'
? 'Diese Signatur-Station wurde von einer neueren Station abgelöst.'
: 'This signature station has been replaced by a newer station.';
warning.style.display = 'block';
}
// Nicht automatisch neu verbinden, um Ping-Pong zu vermeiden
shouldReconnect = false;
try {
ws.close();
} catch (error) {
console.error('Fehler beim Schließen der WebSocket-Verbindung nach Ersatz:', error);
}
} else if (data.type === 'pdf') {
console.log('PDF empfangen');
currentPdf = new Uint8Array(data.pdf);
@@ -113,7 +134,11 @@ function connectWebSocket() {
ws.onclose = () => {
console.log('WebSocket getrennt');
setTimeout(connectWebSocket, 1000);
if (shouldReconnect) {
setTimeout(connectWebSocket, 1000);
} else {
console.log('Automatischer Reconnect ist deaktiviert (Station wurde ersetzt)');
}
};
}