add sendWsBroadcastToGame

This commit is contained in:
Sainan 2025-09-08 05:52:25 +02:00
parent 922e0fb124
commit 370b0c19ea
7 changed files with 21 additions and 12 deletions

View File

@ -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;

View File

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

View File

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

View File

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

View File

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

View File

@ -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 {

View File

@ -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 => {