20 lines
501 B
TypeScript
20 lines
501 B
TypeScript
import { type ServerWebSocket } from "bun";
|
|
import type { WebSocketData } from "@WS/.";
|
|
|
|
type Param = {
|
|
ws: ServerWebSocket<WebSocketData>;
|
|
};
|
|
|
|
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);
|
|
}
|
|
}
|