v1.4.3 - persistent device ID via localStorage so refresh reuses same client slot

This commit is contained in:
jessikitty
2026-06-10 07:02:57 +00:00
parent 581f6ee87b
commit 10f9683e81
3 changed files with 19 additions and 20 deletions
+8 -2
View File
@@ -90,8 +90,14 @@ wss.on('connection', (ws, req) => {
log('WS admin: ' + ip);
ws.send(JSON.stringify({ type: 'clientList', clients: getClientList() }));
} else {
clients.set(id, { id, ws, name:'', ip, userAgent:ua, connectedAt:now, firstSeen:now, lastSeen:Date.now(), status:msg.status||'idle', config:msg.config||{}, source:msg.source||null });
log('WS frame: ' + id + ' (' + ip + ')');
const pid = msg.persistentId || null;
const existing = pid ? Array.from(clients.values()).find(c => c.persistentId === pid) : null;
const effectiveId = existing ? existing.id : id;
const firstName = existing ? existing.name : '';
const firstSeen = existing ? existing.firstSeen : now;
if (existing) { clients.delete(Array.from(clients.entries()).find(([,c]) => c.persistentId === pid)?.[0]); }
clients.set(effectiveId, { id:effectiveId, persistentId:pid, ws, name:firstName, ip, userAgent:ua, connectedAt:now, firstSeen, lastSeen:Date.now(), status:msg.status||'idle', config:msg.config||{}, source:msg.source||null });
log('WS frame: ' + effectiveId + (pid?' [persistent]':'') + ' (' + ip + ')');
broadcastAdminClients();
}
} else if (msg.type === 'ping') {