This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import type { FastifyInstance } from 'fastify'
|
import type { FastifyInstance } from 'fastify'
|
||||||
|
import type { Namespace } from '../types/webrtc.ts'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
import prisma from '../prisma/client.ts'
|
import prisma from '../prisma/client.ts'
|
||||||
import { socketToClient } from '../utils/socket-to-client.ts'
|
import { socketToClient } from '../utils/socket-to-client.ts'
|
||||||
@@ -69,16 +70,13 @@ export default function (fastify: FastifyInstance) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const namespace = fastify.io.of('/webrtc')
|
const namespace: Namespace = fastify.io.of('/webrtc')
|
||||||
const sockets = await namespace.fetchSockets()
|
const sockets = await namespace.fetchSockets()
|
||||||
|
|
||||||
console.log(sockets)
|
const found = sockets.find(socket => socket.data.joined && socket.data.userId === req.user!.id)
|
||||||
|
|
||||||
const found = sockets.find(socket => socket.id === req.user!.id)
|
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
found.data.displayName = input.displayName
|
found.data.displayName = input.displayName
|
||||||
console.log('found.', found)
|
|
||||||
namespace.emit('clientChanged', found.id, socketToClient(found))
|
namespace.emit('clientChanged', found.id, socketToClient(found))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user