v1.4.3 - persistent device ID via localStorage so refresh reuses same client slot
This commit is contained in:
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user