refactorizaciones

This commit is contained in:
2024-04-04 02:02:37 +02:00
parent b460bd6c65
commit c27de6f4f0
5 changed files with 28 additions and 19 deletions

View File

@@ -7,6 +7,7 @@ import {
} from '@nestjs/websockets';
import { SalaChatService } from './sala-chat.service';
import { Server, Socket } from 'socket.io';
import { Resp } from 'src/interfaces/resp';
@WebSocketGateway({ namespace: 'salachat' })
export class SalaChatGateway
@@ -43,13 +44,14 @@ export class SalaChatGateway
}
client.leave('chat_general');
}
@SubscribeMessage('chatMsg')
handleMsg(client: Socket, msg: string) {
const userId = client.handshake.auth.userId;
const user = this.salaChatService.getUsuarioUUID(userId);
if (user) {
this.server.to('chat_general').emit('chatMsg', { uuid: userId, msg });
if (user) {
client.broadcast.to('chat_general').emit('chatMsg',{ uuid: userId, msg });
return { uuid: userId, msg };
} else {
client.disconnect();
}

View File

@@ -57,7 +57,6 @@ export class SalaChatService {
creaPartida(uuidJugadorCreador: string) {
const partida = this.partidasService.creaPartida(uuidJugadorCreador);
this.usuariosService.addPartidaToUsuario(uuidJugadorCreador, partida);
return partida;
}
}