17 lines
434 B
TypeScript
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)
|
|
})
|
|
}
|