refactorizaciones
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ export class SalaChatService {
|
||||
|
||||
creaPartida(uuidJugadorCreador: string) {
|
||||
const partida = this.partidasService.creaPartida(uuidJugadorCreador);
|
||||
this.usuariosService.addPartidaToUsuario(uuidJugadorCreador, partida);
|
||||
return partida;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user