LoginHandler.ts 452 Bytes
import { Connection } from "../../connection/Connection";
import { RoomManager } from "../../room/RoomManager";
import { User } from "../../user/User";
import { LoginMessage } from "../types";

export function loginHandler(
  connection: Connection,
  message: LoginMessage
): void {
  connection.user = new User(message.username, connection);
  console.log(`User ${message.username} has logged in!`);

  RoomManager.instance().sendList(connection);
}