import { WebSocketMessageParam } from "@/src/types";
import sendData from "../(utils)/send-data";
import sendError from "../(utils)/send-error";
import grabConnectedWebsocketUserdata from "../(utils)/grab-connected-websocket-user-data";

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

        console.log("connected_user_data", connected_user_data);

        sendData(ws, {
            event: "server:ping",
        });
    } catch (error: any) {
        sendError(ws, "Client Ping Error! " + error.message);
    }
}
