roomJoinHandler.ts
473 Bytes
import { Connection } from "../../connection/Connection";
import { RoomManager } from "../../room/RoomManager";
import { User } from "../../user/User";
import { MessageResponse, RoomJoinMessage } from "../types";
export function roomJoinHandler(
user: User,
message: RoomJoinMessage
): MessageResponse {
const room = RoomManager.instance().get(message.uuid);
if (room !== undefined) {
room.connect(user);
return { ok: true };
}
return { ok: false };
}