Only one Sighnstation can connect

This commit is contained in:
2026-01-15 21:35:11 +01:00
parent 01dad3025c
commit 2e96470a60
4 changed files with 57 additions and 1 deletions

View File

@@ -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');