Files
chad/server/utils/socket-to-client.ts
2026-04-12 22:35:47 +06:00

17 lines
568 B
TypeScript

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,
username: socket.data.username,
displayName: socket.data.displayName,
inputMuted: socket.data.inputMuted,
outputMuted: socket.data.outputMuted,
currentChannelId: channelId,
}
}