From 370b0c19ea92939ad97350961ddb4ef9c58ab18e Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Mon, 8 Sep 2025 05:52:25 +0200 Subject: [PATCH] add sendWsBroadcastToGame --- src/controllers/api/infestedFoundryController.ts | 4 ++-- .../custom/unlockAllCapturaScenesController.ts | 4 ++-- src/controllers/custom/unlockAllIntrinsicsController.ts | 4 ++-- .../custom/unlockAllProfitTakerStagesController.ts | 4 ++-- .../custom/unlockAllSimarisResearchEntriesController.ts | 4 ++-- src/controllers/custom/updateFingerprintController.ts | 4 ++-- src/services/wsService.ts | 9 +++++++++ 7 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/controllers/api/infestedFoundryController.ts b/src/controllers/api/infestedFoundryController.ts index 27510f80..f46abd6c 100644 --- a/src/controllers/api/infestedFoundryController.ts +++ b/src/controllers/api/infestedFoundryController.ts @@ -20,7 +20,7 @@ import { applyCheatsToInfestedFoundry, handleSubsumeCompletion } from "../../services/infestedFoundryService.ts"; -import { sendWsBroadcastTo } from "../../services/wsService.ts"; +import { sendWsBroadcastToGame } from "../../services/wsService.ts"; export const infestedFoundryController: RequestHandler = async (req, res) => { const account = await getAccountForRequest(req); @@ -364,7 +364,7 @@ export const infestedFoundryController: RequestHandler = async (req, res) => { ); addRecipes(inventory, recipeChanges); await inventory.save(); - sendWsBroadcastTo(account._id.toString(), { sync_inventory: true }); + sendWsBroadcastToGame(account._id.toString(), { sync_inventory: true }); } res.end(); break; diff --git a/src/controllers/custom/unlockAllCapturaScenesController.ts b/src/controllers/custom/unlockAllCapturaScenesController.ts index 7565ffa2..a5eb6215 100644 --- a/src/controllers/custom/unlockAllCapturaScenesController.ts +++ b/src/controllers/custom/unlockAllCapturaScenesController.ts @@ -2,7 +2,7 @@ import type { RequestHandler } from "express"; import { ExportResources, ExportVirtuals } from "warframe-public-export-plus"; import { getAccountIdForRequest } from "../../services/loginService.ts"; import { addItem, getInventory } from "../../services/inventoryService.ts"; -import { sendWsBroadcastTo } from "../../services/wsService.ts"; +import { sendWsBroadcastToGame } from "../../services/wsService.ts"; export const unlockAllCapturaScenesController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); @@ -19,7 +19,7 @@ export const unlockAllCapturaScenesController: RequestHandler = async (req, res) await inventory.save(); res.end(); if (needSync) { - sendWsBroadcastTo(accountId, { sync_inventory: true }); + sendWsBroadcastToGame(accountId, { sync_inventory: true }); } }; diff --git a/src/controllers/custom/unlockAllIntrinsicsController.ts b/src/controllers/custom/unlockAllIntrinsicsController.ts index ad7fc107..6e61596f 100644 --- a/src/controllers/custom/unlockAllIntrinsicsController.ts +++ b/src/controllers/custom/unlockAllIntrinsicsController.ts @@ -1,7 +1,7 @@ import { getInventory } from "../../services/inventoryService.ts"; import { getAccountIdForRequest } from "../../services/loginService.ts"; import type { RequestHandler } from "express"; -import { sendWsBroadcastTo } from "../../services/wsService.ts"; +import { sendWsBroadcastToGame } from "../../services/wsService.ts"; export const unlockAllIntrinsicsController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); @@ -17,5 +17,5 @@ export const unlockAllIntrinsicsController: RequestHandler = async (req, res) => inventory.PlayerSkills.LPS_DRIFT_ENDURANCE = 10; await inventory.save(); res.end(); - sendWsBroadcastTo(accountId, { sync_inventory: true }); + sendWsBroadcastToGame(accountId, { sync_inventory: true }); }; diff --git a/src/controllers/custom/unlockAllProfitTakerStagesController.ts b/src/controllers/custom/unlockAllProfitTakerStagesController.ts index 4c362d3d..a46dd23b 100644 --- a/src/controllers/custom/unlockAllProfitTakerStagesController.ts +++ b/src/controllers/custom/unlockAllProfitTakerStagesController.ts @@ -1,7 +1,7 @@ import { getInventory } from "../../services/inventoryService.ts"; import { getAccountIdForRequest } from "../../services/loginService.ts"; import type { RequestHandler } from "express"; -import { sendWsBroadcastTo } from "../../services/wsService.ts"; +import { sendWsBroadcastToGame } from "../../services/wsService.ts"; const allEudicoHeistJobs = [ "/Lotus/Types/Gameplay/Venus/Jobs/Heists/HeistProfitTakerBountyOne", @@ -22,5 +22,5 @@ export const unlockAllProfitTakerStagesController: RequestHandler = async (req, } await inventory.save(); res.end(); - sendWsBroadcastTo(accountId, { sync_inventory: true }); + sendWsBroadcastToGame(accountId, { sync_inventory: true }); }; diff --git a/src/controllers/custom/unlockAllSimarisResearchEntriesController.ts b/src/controllers/custom/unlockAllSimarisResearchEntriesController.ts index a12626dd..3e013292 100644 --- a/src/controllers/custom/unlockAllSimarisResearchEntriesController.ts +++ b/src/controllers/custom/unlockAllSimarisResearchEntriesController.ts @@ -1,7 +1,7 @@ import type { RequestHandler } from "express"; import { getAccountIdForRequest } from "../../services/loginService.ts"; import { getInventory } from "../../services/inventoryService.ts"; -import { sendWsBroadcastTo } from "../../services/wsService.ts"; +import { sendWsBroadcastToGame } from "../../services/wsService.ts"; export const unlockAllSimarisResearchEntriesController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); @@ -18,5 +18,5 @@ export const unlockAllSimarisResearchEntriesController: RequestHandler = async ( ].map(type => ({ TargetType: type, Scans: 10, Completed: true })); await inventory.save(); res.end(); - sendWsBroadcastTo(accountId, { sync_inventory: true }); + sendWsBroadcastToGame(accountId, { sync_inventory: true }); }; diff --git a/src/controllers/custom/updateFingerprintController.ts b/src/controllers/custom/updateFingerprintController.ts index 48e83c85..8278744e 100644 --- a/src/controllers/custom/updateFingerprintController.ts +++ b/src/controllers/custom/updateFingerprintController.ts @@ -2,7 +2,7 @@ import { getInventory } from "../../services/inventoryService.ts"; import type { WeaponTypeInternal } from "../../services/itemDataService.ts"; import { getAccountIdForRequest } from "../../services/loginService.ts"; import type { RequestHandler } from "express"; -import { sendWsBroadcastTo } from "../../services/wsService.ts"; +import { sendWsBroadcastToGame } from "../../services/wsService.ts"; export const updateFingerprintController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); @@ -23,7 +23,7 @@ export const updateFingerprintController: RequestHandler = async (req, res) => { await inventory.save(); } res.end(); - sendWsBroadcastTo(accountId, { sync_inventory: true }); + sendWsBroadcastToGame(accountId, { sync_inventory: true }); }; interface IUpdateFingerPrintRequest { diff --git a/src/services/wsService.ts b/src/services/wsService.ts index 74bad174..87a834d7 100644 --- a/src/services/wsService.ts +++ b/src/services/wsService.ts @@ -222,6 +222,15 @@ export const sendWsBroadcastTo = (accountId: string, data: IWsMsgToClient): void }); }; +export const sendWsBroadcastToGame = (accountId: string, data: IWsMsgToClient): void => { + const msg = JSON.stringify(data); + forEachClient(client => { + if (client.isGame && client.accountId == accountId) { + client.send(msg); + } + }); +}; + export const sendWsBroadcastEx = (data: IWsMsgToClient, accountId: string | undefined, excludeWsid: number): void => { const msg = JSON.stringify(data); forEachClient(client => {