import { type ServerWebSocket } from "bun"; import type { WebSocketData } from "@WS/."; type Param = { ws: ServerWebSocket; }; export default async function socketClose({ ws }: Param) { const user = ws.data.user; console.log(`Web Closed by ${user.first_name}`); const userSessionIndex = global.ACTIVE_USERS.findIndex( (session) => session.id == user.id ); if (userSessionIndex >= 0) { global.ACTIVE_USERS.splice(userSessionIndex, 1); } }