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))); } };