update
This commit is contained in:
@@ -32,7 +32,7 @@ export class SocketGateway implements OnGatewayConnection {
|
||||
|
||||
@SubscribeMessage('sendMessageToClients')
|
||||
async handleSendMessage(sendMessageDto: SendMessageDto) {
|
||||
const clients = this.getConnectedClients(sendMessageDto.auths);
|
||||
const clients = this.getConnectedClients(sendMessageDto.clientsId);
|
||||
if (clients.length === 0) {
|
||||
return {
|
||||
status: 0,
|
||||
@@ -42,19 +42,19 @@ export class SocketGateway implements OnGatewayConnection {
|
||||
|
||||
const result = await this.socketService.sendMessageToClients(
|
||||
clients,
|
||||
sendMessageDto.data,
|
||||
sendMessageDto.message,
|
||||
sendMessageDto.event,
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
getConnectedClients(auths: string[]): Socket[] {
|
||||
getConnectedClients(clientsId: string[]): Socket[] {
|
||||
const connectedClients = this.server.sockets.sockets;
|
||||
const clients: Socket[] = [];
|
||||
|
||||
for (const client of connectedClients.values()) {
|
||||
if (auths.includes(client.handshake.auth.token)) {
|
||||
if (clientsId.includes(client.handshake.auth.token)) {
|
||||
clients.push(client);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user