Only one Sighnstation can connect
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,13 @@
|
||||
<div class="icon">📄</div>
|
||||
<h2>Warte auf PDF...</h2>
|
||||
<p>Bereit zum Unterschreiben. Lade ein PDF auf der Master-Station hoch.</p>
|
||||
<div id="alreadyConnectedWarning" class="already-connected-warning" style="display: none;">
|
||||
<div class="warning-icon">⚠️</div>
|
||||
<div class="warning-text">
|
||||
<strong>Hinweis:</strong> Bereits eine andere Signatur-Station ist mit dem Master verbunden.
|
||||
Diese Station kann nicht verwendet werden, solange die andere Station aktiv ist.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="signatureSection" style="display: none;">
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
14
server.js
14
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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user