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

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