feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration / RRScratch2 / Math Adjustments / DMS State cleaning on Page load
This commit is contained in:
@@ -115,6 +115,33 @@ function SetLegacyWebsocketHandlers(io) {
|
||||
socket.on("disconnect", () => {
|
||||
createLogEvent(socket, "DEBUG", `User disconnected.`);
|
||||
});
|
||||
|
||||
// DMS reset for legacy WS (CDK / PBS)
|
||||
socket.on("dms-reset-context", ({ jobId, mode } = {}, ack) => {
|
||||
try {
|
||||
// Clear any per-socket DMS state that can leak across jobs
|
||||
socket.selectedCustomerId = null; // CDK / PBS AR
|
||||
socket.txEnvelope = null; // PBS AP export
|
||||
socket.apAllocations = null; // PBS AP allocations
|
||||
|
||||
createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`DMS reset-context (legacy WS): cleared per-socket state` +
|
||||
(jobId ? ` (jobId=${jobId})` : "") +
|
||||
(mode ? ` (mode=${mode})` : "")
|
||||
);
|
||||
|
||||
if (typeof ack === "function") {
|
||||
ack({ ok: true });
|
||||
}
|
||||
} catch (error) {
|
||||
createLogEvent(socket, "ERROR", `DMS reset-context (legacy WS) failed: ${error.message}`);
|
||||
if (typeof ack === "function") {
|
||||
ack({ ok: false, error: error.message });
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user