front update
All checks were successful
Deploy / deploy (push) Successful in 38s

This commit is contained in:
Никита Круглицкий
2025-10-09 06:14:35 +06:00
parent fc43c8df96
commit e2064dba6c
11 changed files with 122 additions and 22 deletions

View File

@@ -18,8 +18,11 @@ const ICE_SERVERS: RTCIceServer[] = [
]
export const useMediasoup = createSharedComposable(() => {
const preferences = usePreferences()
const toast = useToast()
const signaling = useSignaling()
const { addClient, removeClient } = useClients()
const preferences = usePreferences()
const device = shallowRef<mediasoupClient.Device>()
const rtpCapabilities = shallowRef<mediasoupClient.types.RtpCapabilities>()
@@ -30,8 +33,6 @@ export const useMediasoup = createSharedComposable(() => {
const webcamProducer = shallowRef<mediasoupClient.types.Producer>()
const shareProducer = shallowRef<mediasoupClient.types.Producer>()
const clients = shallowRef<ChadClient[]>([])
const consumers = shallowRef<Map<string, mediasoupClient.types.Consumer>>(new Map())
const producers = shallowRef<Map<string, mediasoupClient.types.Producer>>(new Map())
@@ -121,21 +122,24 @@ export const useMediasoup = createSharedComposable(() => {
})
}
clients.value = (await signaling.socket.value.emitWithAck('join', {
const joinedClients = (await signaling.socket.value.emitWithAck('join', {
username: preferences.username.value,
rtpCapabilities: rtpCapabilities.value,
})).map(transformClient)
addClient(...joinedClients)
toast.add({ severity: 'success', summary: 'Joined', closable: false, life: 1000 })
await enableMic()
})
socket.on('newPeer', (client) => {
clients.value.push(transformClient(client))
triggerRef(clients)
addClient(transformClient(client))
})
socket.on('peerClosed', (id) => {
clients.value = clients.value.filter(client => client.id !== id)
removeClient(id)
})
socket.on(
@@ -317,7 +321,6 @@ export const useMediasoup = createSharedComposable(() => {
return {
init,
clients,
consumers,
producers,
sendTransport,