diff --git a/src/app.ts b/src/app.ts index 8e105830..344c521e 100644 --- a/src/app.ts +++ b/src/app.ts @@ -17,9 +17,10 @@ import { ProfileSalaryController } from "./controllers/ProfileSalaryController"; import { WebSocketServer } from "ws"; import http from "http"; export const wss = new WebSocketServer({ noServer: true, - path: "/api/vi/org/socket", + path: "/api/v1/org-socket", }); + async function main() { await AppDataSource.initialize(); diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 13fabffb..c9fadc2e 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -31,7 +31,7 @@ import { Profile } from "../entities/Profile"; import { viewRegistryOfficer } from "../entities/view/viewRegistryOfficer"; import { viewRegistryEmployee } from "../entities/view/viewRegistryEmployee"; import { EmployeeTempPosMaster } from "../entities/EmployeeTempPosMaster"; -// import { sendWebSocket } from "../services/webSocket"; +import { sendWebSocket } from "../services/webSocket"; @Route("api/v1/org/report") @Tags("Report") @@ -3537,14 +3537,11 @@ export class ReportController extends Controller { } } } -<<<<<<< HEAD -======= - // const metaData = { template: "report2", reportName: "report2", data: { data } }; - // sendWebSocket(metaData) + const metaData = { template: "report2", reportName: "report2", data: { data } }; + sendWebSocket(metaData) ->>>>>>> b24a900198a2e83d621975fe9d657157de8ffccf - return new HttpSuccess({ template: "report2", reportName: "report2", data: { data } }); + // return new HttpSuccess({ template: "report2", reportName: "report2", data: { data } }); } /** diff --git a/src/services/webSocket.ts b/src/services/webSocket.ts index 23062aba..5dd006f0 100644 --- a/src/services/webSocket.ts +++ b/src/services/webSocket.ts @@ -1,16 +1,16 @@ -// import { WebSocket } from "ws"; -// import { wss } from "../app"; +import { WebSocket } from "ws"; +import { wss } from "../app"; -// export async function sendWebSocket(data:any){ -// wss.clients.forEach((client: any) => { -// if (client.readyState === WebSocket.OPEN) { -// const message = JSON.stringify(data); -// console.log("📤 Sending data to client:", message); -// client.send(message, (err:any) => { -// if (err) { -// console.error("❌ Error sending message:", err); -// } -// }); -// } -// }); -// } \ No newline at end of file +export async function sendWebSocket(data:any){ + wss.clients.forEach((client: any) => { + if (client.readyState === WebSocket.OPEN) { + const message = JSON.stringify(data); + console.log("📤 Sending data to client:", message); + client.send(message, (err:any) => { + if (err) { + console.error("❌ Error sending message:", err); + } + }); + } + }); +} \ No newline at end of file