LoginHandler.ts
504 Bytes
import { Connection } from "../../connection/Connection";
import { RoomManager } from "../../room/RoomManager";
import { User } from "../../user/User";
import { LoginMessage, MessageResponse } from "../types";
export function loginHandler(
connection: Connection,
message: LoginMessage
): MessageResponse {
connection.user = new User(message.username, connection);
console.log(`User ${message.username} has logged in!`);
RoomManager.instance().sendList(connection);
return { ok: true };
}