diff --git a/css/signature.css b/css/signature.css
index f8bfb0d..474b476 100644
--- a/css/signature.css
+++ b/css/signature.css
@@ -194,3 +194,31 @@ body {
font-size: 3em;
margin-bottom: 20px;
}
+
+.already-connected-warning {
+ margin-top: 25px;
+ padding: 15px;
+ background: #fff3cd;
+ border: 2px solid #ffc107;
+ border-radius: 8px;
+ display: flex;
+ align-items: flex-start;
+ gap: 12px;
+ text-align: left;
+}
+
+.already-connected-warning .warning-icon {
+ font-size: 1.8em;
+ flex-shrink: 0;
+}
+
+.already-connected-warning .warning-text {
+ flex: 1;
+ color: #856404;
+ font-size: 0.95em;
+ line-height: 1.5;
+}
+
+.already-connected-warning .warning-text strong {
+ font-weight: 600;
+}
diff --git a/html/signature.html b/html/signature.html
index abb3bb8..cf64a2a 100644
--- a/html/signature.html
+++ b/html/signature.html
@@ -24,6 +24,13 @@
📄
Warte auf PDF...
Bereit zum Unterschreiben. Lade ein PDF auf der Master-Station hoch.
+
+
⚠️
+
+ Hinweis: Bereits eine andere Signatur-Station ist mit dem Master verbunden.
+ Diese Station kann nicht verwendet werden, solange die andere Station aktiv ist.
+
+
diff --git a/js/signature.js b/js/signature.js
index 3bcf3a9..4d8c4bf 100644
--- a/js/signature.js
+++ b/js/signature.js
@@ -38,7 +38,14 @@ function connectWebSocket() {
ws.onmessage = async (event) => {
const data = JSON.parse(event.data);
- if (data.type === 'pdf') {
+ if (data.type === 'already_connected') {
+ console.log('⚠️ Bereits eine andere Signatur-Station verbunden');
+ // Show warning message
+ const warning = document.getElementById('alreadyConnectedWarning');
+ if (warning) {
+ warning.style.display = 'block';
+ }
+ } else if (data.type === 'pdf') {
console.log('PDF empfangen');
currentPdf = new Uint8Array(data.pdf);
diff --git a/server.js b/server.js
index 1c52a18..f7e61b6 100644
--- a/server.js
+++ b/server.js
@@ -205,6 +205,20 @@ function handleMasterRegister(ws) {
}
function handleSignatureRegister(ws) {
+ // Check if another signature station is already connected
+ if (signatureConnection && signatureConnection.readyState === WebSocket.OPEN) {
+ // Inform the new station that another station is already connected
+ ws.send(JSON.stringify({
+ type: 'already_connected'
+ }));
+ console.log('⚠️ Neue Signatur-Station versucht sich zu verbinden, aber bereits eine Station verbunden');
+ console.log('⚠️ Neue Station wurde informiert, alte Station bleibt aktiv');
+ // Keep the old connection, don't replace it
+ // Don't register the new connection as signatureConnection
+ return; // Exit without registering the new connection
+ }
+
+ // No existing connection, register this new one
signatureConnection = ws;
console.log('Signatur-Station registriert');