cringe sfx

This commit is contained in:
2026-04-12 22:35:47 +06:00
parent 7b2cfb4b56
commit 92f7bae50d
15 changed files with 700 additions and 597 deletions

View File

@@ -0,0 +1,16 @@
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)
})
}

View File

@@ -1,6 +1,9 @@
import type { ChadClient, SomeSocket } from '../types/socket.ts'
export function socketToClient(socket: SomeSocket): ChadClient {
// Socket.IO rooms: Extract channel room (filter out the socket's own room)
const channelId = Array.from(socket.rooms).find(room => room !== socket.id) || 'default'
return {
socketId: socket.id,
userId: socket.data.userId,
@@ -8,5 +11,6 @@ export function socketToClient(socket: SomeSocket): ChadClient {
displayName: socket.data.displayName,
inputMuted: socket.data.inputMuted,
outputMuted: socket.data.outputMuted,
currentChannelId: channelId,
}
}