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

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