import { OnGatewayConnection, OnGatewayDisconnect, OnGatewayInit, SubscribeMessage, WebSocketGateway } from '@nestjs/websockets';
import { LoginService } from './login.service';
import { Socket } from 'socket.io';

@WebSocketGateway({namespace:'login'})
export class LoginGateway implements OnGatewayConnection, OnGatewayDisconnect{
  constructor(private readonly loginService: LoginService) {}
  
  handleConnection(client: any, ...args: any[]) {    
  }
  handleDisconnect(client: any) {
  }

  @SubscribeMessage('login')
  handleLogin(client: Socket, nick: string){
    return this.loginService.login(nick);
  }
}
