feat: implement Server-Sent Events (SSE) for real-time updates and notifications

This commit is contained in:
Jokob @NetAlertX
2026-01-11 06:15:27 +00:00
parent 6deb83a53d
commit 5a0332bba5
11 changed files with 621 additions and 32 deletions

View File

@@ -5,6 +5,7 @@ from const import applicationPath, apiPath
from logger import mylog
from helper import checkNewVersion
from utils.datetime_utils import timeNowDB, timeNow
from api_server.sse_broadcast import broadcast_state_update
# Register NetAlertX directories using runtime configuration
INSTALL_PATH = applicationPath
@@ -151,6 +152,12 @@ class app_state_class:
except (TypeError, ValueError) as e:
mylog("none", [f"[app_state_class] Failed to serialize object to JSON: {e}"],)
# Broadcast state change via SSE if available
try:
broadcast_state_update(self.currentState, self.settingsImported, timestamp=self.lastUpdated)
except Exception as e:
mylog("none", [f"[app_state] SSE broadcast: {e}"])
return