Letzte Station bekommt prio
This commit is contained in:
@@ -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)');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user