From a5cda8828f6bbbbca021c0e83f0d838cc2a20f23 Mon Sep 17 00:00:00 2001 From: opti1337 Date: Fri, 26 Dec 2025 01:22:34 +0600 Subject: [PATCH] refactor --- server/routes/user.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/server/routes/user.ts b/server/routes/user.ts index 1f498f1..6272104 100644 --- a/server/routes/user.ts +++ b/server/routes/user.ts @@ -1,4 +1,5 @@ import type { FastifyInstance } from 'fastify' +import type { Namespace } from '../types/webrtc.ts' import { z } from 'zod' import prisma from '../prisma/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() - console.log(sockets) - - const found = sockets.find(socket => socket.id === req.user!.id) + const found = sockets.find(socket => socket.data.joined && socket.data.userId === req.user!.id) if (found) { found.data.displayName = input.displayName - console.log('found.', found) namespace.emit('clientChanged', found.id, socketToClient(found)) }