From 3d594a99d56c4a1217329d1dc2d6d05bae4bf9ef Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Tue, 28 May 2024 22:41:50 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8(frontend)=20add=20room=20to=20ws?= =?UTF-8?q?=20signaling=20url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the room to the ws signaling url so that the ingress controller can route the request to the correct pod. --- .../apps/e2e/__tests__/app-impress/pad-editor.spec.ts | 2 +- src/frontend/apps/impress/src/core/conf.ts | 10 +++++++--- .../features/pads/pad-editor/stores/usePadStore.tsx | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/frontend/apps/e2e/__tests__/app-impress/pad-editor.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/pad-editor.spec.ts index 6ce99185..ed30c9f3 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/pad-editor.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/pad-editor.spec.ts @@ -33,7 +33,7 @@ test.describe('Pad Editor', () => { await expect(page.locator('h2').getByText(randomPad[0])).toBeVisible(); const webSocket = await webSocketPromise; - expect(webSocket.url()).toBe('ws://localhost:4444/'); + expect(webSocket.url()).toContain('ws://localhost:4444/'); const framesentPromise = webSocket.waitForEvent('framesent'); diff --git a/src/frontend/apps/impress/src/core/conf.ts b/src/frontend/apps/impress/src/core/conf.ts index d26686c8..08ad216f 100644 --- a/src/frontend/apps/impress/src/core/conf.ts +++ b/src/frontend/apps/impress/src/core/conf.ts @@ -6,6 +6,10 @@ export const baseApiUrl = () => { return `${origin}${process.env.NEXT_PUBLIC_API_URL}`; }; -export const signalingUrl = () => - process.env.NEXT_PUBLIC_SIGNALING_URL || - (typeof window !== 'undefined' ? `wss://${window.location.host}/ws` : ''); +export const signalingUrl = (padId: string) => { + const base = + process.env.NEXT_PUBLIC_SIGNALING_URL || + (typeof window !== 'undefined' ? `wss://${window.location.host}/ws` : ''); + + return `${base}/${padId}`; +}; diff --git a/src/frontend/apps/impress/src/features/pads/pad-editor/stores/usePadStore.tsx b/src/frontend/apps/impress/src/features/pads/pad-editor/stores/usePadStore.tsx index a4a58ed5..31c4367d 100644 --- a/src/frontend/apps/impress/src/features/pads/pad-editor/stores/usePadStore.tsx +++ b/src/frontend/apps/impress/src/features/pads/pad-editor/stores/usePadStore.tsx @@ -31,7 +31,8 @@ export const usePadStore = create((set) => ({ } const provider = new WebrtcProvider(padId, doc, { - signaling: [signalingUrl()], + signaling: [signalingUrl(padId)], + maxConns: 5, }); set(({ padsStore }) => {