import { WebSocketMessageParam } from "@/src/types";
import sendData from "../(utils)/send-data";
import sendError from "../(utils)/send-error";
import killAllTtydPorts from "../(utils)/kill-all-ttyd-ports";

export default async function socketClientKillAllPorts({
    ws,
    data,
}: WebSocketMessageParam) {
    try {
        const user = ws.data.user;

        await killAllTtydPorts({ user });

        sendData(ws, {
            event: "server:killed-all-ports",
        });
    } catch (error: any) {
        sendError(ws, "Service Server Logs Error! " + error.message);
    }
}
