import type { ServerWebSocket } from "bun";
import type { WebSocketData } from "..";
import type { WebSocketDataType } from "@/types";
import datasquirel from "@moduletrace/datasquirel";
const EJSON = datasquirel.client.utils.EJSON;

export default function sendMessage(
    ws: ServerWebSocket<WebSocketData>,
    message: String
) {
    ws.send(
        String(
            EJSON.stringify({
                event: "server:message",
                message: message,
            } as WebSocketDataType)
        )
    );
}
