This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-03-06 16:33:47 +07:00
parent 2c13dae452
commit e69fd7b33b
2 changed files with 43 additions and 31 deletions

View file

@ -32,6 +32,9 @@ import { viewRegistryOfficer } from "../entities/view/viewRegistryOfficer";
import { viewRegistryEmployee } from "../entities/view/viewRegistryEmployee";
import { EmployeeTempPosMaster } from "../entities/EmployeeTempPosMaster";
import { WebSocket } from "ws";
import { wss } from "../app"; // ✅ Import clients
@Route("api/v1/org/report")
@Tags("Report")
@Security("bearerAuth")
@ -3537,8 +3540,19 @@ export class ReportController extends Controller {
}
}
}
return new HttpSuccess({ template: "report2", reportName: "report2", data: { data } });
// ✅ ส่งข้อมูลไปยังทุกไคลเอนต์ที่เชื่อมต่อ WebSocket
wss.clients.forEach((client) => {
if (client.readyState === WebSocket.OPEN) {
if (client.readyState === 1) {
client.send(
JSON.stringify({ template: "report2", reportName: "report2", data: { data } }),
);
}
}
});
// return new HttpSuccess({ template: "report2", reportName: "report2", data: { data } });
}
/**