Files
chad/server/utils/fetch-sockets.ts
2026-04-12 22:35:47 +06:00

17 lines
434 B
TypeScript

import type { SocketServer } from '../types/socket.ts'
export async function fetchSockets(io: SocketServer, excludeId?: string, channelId?: string) {
let sockets: Awaited<ReturnType<typeof io.fetchSockets>>
if (channelId) {
sockets = await io.in(channelId).fetchSockets()
}
else {
sockets = await io.fetchSockets()
}
return sockets.filter((socket) => {
return !(excludeId && socket.id === excludeId)
})
}