From 6d8ade073aa2143f6e47bc63575d16ced01db9f3 Mon Sep 17 00:00:00 2001 From: Timo K Date: Sun, 25 Jan 2026 19:27:01 +0100 Subject: [PATCH] use sessionManager with custom slot instead of only session. --- sdk/main.ts | 21 ++++++++++++++++----- yarn.lock | 4 ++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/sdk/main.ts b/sdk/main.ts index f56b45a5..8cc8be76 100644 --- a/sdk/main.ts +++ b/sdk/main.ts @@ -30,8 +30,8 @@ import { } from "rxjs"; import { type CallMembership, - MatrixRTCSession, MatrixRTCSessionEvent, + MatrixRTCSessionManager, } from "matrix-js-sdk/lib/matrixrtc"; import { type Room as LivekitRoom, @@ -87,25 +87,35 @@ export async function createMatrixRTCSdk( id: string = "", sticky: boolean = false, ): Promise { + const scope = new ObservableScope(); + + // widget client initializeWidget(application); const widget = _widget; if (!widget) throw Error("No widget. This webapp can only start as a widget"); const client = await widget.client; logger.info("client created"); - const scope = new ObservableScope(); + + // url params const { roomId } = getUrlParams(); if (roomId === null) throw Error("could not get roomId from url params"); - const room = client.getRoom(roomId); if (room === null) throw Error("could not get room from client"); + // rtc session + const slot = { application, id }; + const rtcSessionManager = new MatrixRTCSessionManager(logger, client, slot); + rtcSessionManager.start(); + const rtcSession = rtcSessionManager.getRoomSession(room); + + // media devices const mediaDevices = new MediaDevices(scope); const muteStates = new MuteStates(scope, mediaDevices, { audioEnabled: false, videoEnabled: false, }); - const slot = { application, id }; - const rtcSession = new MatrixRTCSession(client, room, slot); + + // call view model const callViewModel = createCallViewModel$( scope, rtcSession, @@ -118,6 +128,7 @@ export async function createMatrixRTCSdk( constant({ supported: false, processor: undefined }), ); logger.info("CallViewModelCreated"); + // create data listener const data$ = new Subject<{ sender: string; data: string }>(); diff --git a/yarn.lock b/yarn.lock index fd7f2302..c162b527 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11454,7 +11454,7 @@ __metadata: "matrix-js-sdk@matrix-org/matrix-js-sdk#develop": version: 40.0.0 - resolution: "matrix-js-sdk@https://github.com/matrix-org/matrix-js-sdk.git#commit=dbb2ae5c0752c28639502e93f26cb3003d0d0595" + resolution: "matrix-js-sdk@https://github.com/matrix-org/matrix-js-sdk.git#commit=61ea5a7dfc37a788c6a586caf85d7d7a5c7b1ef5" dependencies: "@babel/runtime": "npm:^7.12.5" "@matrix-org/matrix-sdk-crypto-wasm": "npm:^17.0.0" @@ -11470,7 +11470,7 @@ __metadata: sdp-transform: "npm:^3.0.0" unhomoglyph: "npm:^1.0.6" uuid: "npm:13" - checksum: 10c0/9f97cec346e0dcce8599bc3afa1608f5166408260937f8311fa9af95b8fd2ff6d86422124fcb721fc830a3ec269389067334c344b4f512b64299561484135326 + checksum: 10c0/9c6e9878d8ff42edb8761b63d398975592698d70d38548d5f27eca6cedfb599242e3a24c8503ff1f0edc326f62f640174291510670bc0cb9282e163800d6f916 languageName: node linkType: hard