LoginHandler.ts
467 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<undefined> {
connection.user = new User(message.username, connection);
console.log(`User ${message.username} has logged in!`);
return { ok: true };
}