LoginHandler.ts
521 Bytes
import { ServerInboundMessageMap, ServerResponse } from "../../../common";
import { Connection } from "../../connection/Connection";
import { RoomManager } from "../../room/RoomManager";
import { User } from "../../user/User";
export function loginHandler(
connection: Connection,
message: ServerInboundMessageMap["login"],
scope: undefined
): ServerResponse<"login"> {
connection.user = new User(message.username, connection);
console.log(`User ${message.username} has logged in!`);
return { ok: true };
}