feat(ws): add wsSendAll utility for multi-instance broadcast

This commit is contained in:
Jannis Braun
2026-03-24 21:52:51 +01:00
parent 0d91df166a
commit 7f4f40a1e5
+9
View File
@@ -1067,6 +1067,15 @@ export function wsSend(event: ClientEvent, origin: string = HOME_ORIGIN): void {
} }
} }
/** Send an event to ALL connected WebSocket instances (home + remotes). */
export function wsSendAll(event: ClientEvent): void {
for (const [_origin, conn] of connections) {
if (conn.ws && conn.ws.readyState === WebSocket.OPEN) {
conn.ws.send(JSON.stringify(event));
}
}
}
/** /**
* Hook to initialize the home WebSocket connection. Should only be called ONCE * Hook to initialize the home WebSocket connection. Should only be called ONCE
* from the top-level layout component (AppLayout). Other components should * from the top-level layout component (AppLayout). Other components should