diff --git a/src/services/webService.ts b/src/services/webService.ts index 9c38dc15..2f5f3e3f 100644 --- a/src/services/webService.ts +++ b/src/services/webService.ts @@ -108,6 +108,23 @@ interface IWsMsgFromClient { }; } +interface IWsMsgToClient { + ports?: { + http: number | undefined; + https: number | undefined; + }; + config_reloaded?: boolean; + auth_succ?: { + id: string; + DisplayName: string; + Nonce: number; + }; + auth_fail?: { + isRegister: boolean; + }; + logged_out?: boolean; +} + const wsOnConnect = (ws: ws, _req: http.IncomingMessage): void => { // eslint-disable-next-line @typescript-eslint/no-misused-promises ws.on("message", async msg => { @@ -144,7 +161,7 @@ const wsOnConnect = (ws: ws, _req: http.IncomingMessage): void => { DisplayName: account.DisplayName, Nonce: account.Nonce } - }) + } satisfies IWsMsgToClient) ); } else { ws.send( @@ -152,14 +169,14 @@ const wsOnConnect = (ws: ws, _req: http.IncomingMessage): void => { auth_fail: { isRegister: data.auth.isRegister } - }) + } satisfies IWsMsgToClient) ); } } }); }; -export const sendWsBroadcast = (data: T): void => { +export const sendWsBroadcast = (data: IWsMsgToClient): void => { const msg = JSON.stringify(data); if (wsServer) { for (const client of wsServer.clients) { @@ -173,7 +190,7 @@ export const sendWsBroadcast = (data: T): void => { } }; -export const sendWsBroadcastTo = (accountId: string, data: T): void => { +export const sendWsBroadcastTo = (accountId: string, data: IWsMsgToClient): void => { const msg = JSON.stringify(data); if (wsServer) { for (const client of wsServer.clients) {