feat: Implement server-initiated status refresh for new device detection and client-requested full status updates.

This commit is contained in:
sebseb7
2026-01-22 02:01:34 -05:00
parent f74467b324
commit 778af32b5e

View File

@@ -631,6 +631,10 @@ const dashboardHTML = `<!DOCTYPE html>
if (!devices[mac]) { if (!devices[mac]) {
// New device, request full refresh // New device, request full refresh
console.log('New device detected (' + mac + '), requesting refresh...');
if (ws && ws.readyState === WebSocket.OPEN) {
ws.send(JSON.stringify({ type: 'get_status' }));
}
return; return;
} }
@@ -961,6 +965,11 @@ wss.on('connection', async (ws) => {
} }
} }
ws.send(JSON.stringify({ type: 'set_config_result', success })); ws.send(JSON.stringify({ type: 'set_config_result', success }));
} else if (data.type === 'get_status') {
// Client requested full status refresh
const devices = await getStatusData();
const rules = await getRulesStatus();
ws.send(JSON.stringify({ type: 'init', devices, rules }));
} }
} catch (err) { } catch (err) {
console.error('[Status] Error processing message:', err); console.error('[Status] Error processing message:', err);