roomChatHandler.ts 469 Bytes
import { ServerInboundMessage, ServerResponse } from "../../../common";
import { Connection } from "../../connection/Connection";
import { Room } from "../../room/Room";
import { RoomManager } from "../../room/RoomManager";
import { User } from "../../user/User";

export function chatHandler(
  connection: Connection,
  message: ServerInboundMessage<"chat">,
  scope: Room
): ServerResponse<"chat"> {
  scope.sendChat(user, message.message);
  return { ok: true };
}