From b812cec358c01d50d782a444668e758137213c13 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Mon, 8 Sep 2025 05:57:39 +0200 Subject: [PATCH] add sendWsBroadcastToWebui --- src/services/wsService.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/services/wsService.ts b/src/services/wsService.ts index edac93bd..752c74b7 100644 --- a/src/services/wsService.ts +++ b/src/services/wsService.ts @@ -240,6 +240,19 @@ export const sendWsBroadcastEx = (data: IWsMsgToClient, accountId: string | unde }); }; +export const sendWsBroadcastToWebui = ( + data: IWsMsgToClient, + accountId: string | undefined, + excludeWsid: number +): void => { + const msg = JSON.stringify(data); + forEachClient(client => { + if (!client.isGame && (!accountId || client.accountId == accountId) && client.id != excludeWsid) { + client.send(msg); + } + }); +}; + export const broadcastInventoryUpdate = (req: Request): void => { const accountId = req.query.accountId as string; if (req.query.wsid) { @@ -251,7 +264,7 @@ export const broadcastInventoryUpdate = (req: Request): void => { ); } else { // for game requests, let all webui tabs know - sendWsBroadcastEx({ update_inventory: true }, accountId, parseInt(String(req.query.wsid))); // TODO: exclude game ws from this somehow + sendWsBroadcastToWebui({ update_inventory: true }, accountId, parseInt(String(req.query.wsid))); } };