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