From 851758be6bb3c83d95c61d651c4d5f195c0ee796 Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Sun, 4 May 2025 16:54:09 +0330 Subject: [PATCH] fixed bug --- src/socket/socket.gateway.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/socket/socket.gateway.ts b/src/socket/socket.gateway.ts index 3348783..32ea9e4 100644 --- a/src/socket/socket.gateway.ts +++ b/src/socket/socket.gateway.ts @@ -9,7 +9,6 @@ import { SendMessageDto } from './dto/sendMessage.dto'; import { SocketService } from './socket.service'; @WebSocketGateway({ - namespace: '/notification', cors: { origin: '*', }, @@ -57,10 +56,12 @@ export class SocketGateway implements OnGatewayConnection { } getConnectedClients(clientsId: string[]): Socket[] { - const connectedClients = this.server.sockets.sockets; + const socketsMap = this.server?.sockets?.sockets; + if (!socketsMap) return []; + const clients: Socket[] = []; - for (const client of connectedClients.values()) { + for (const client of socketsMap.values()) { if (clientsId.includes(client.handshake.auth.token)) { clients.push(client); }