use sessionManager with custom slot instead of only session.
This commit is contained in:
21
sdk/main.ts
21
sdk/main.ts
@@ -30,8 +30,8 @@ import {
|
|||||||
} from "rxjs";
|
} from "rxjs";
|
||||||
import {
|
import {
|
||||||
type CallMembership,
|
type CallMembership,
|
||||||
MatrixRTCSession,
|
|
||||||
MatrixRTCSessionEvent,
|
MatrixRTCSessionEvent,
|
||||||
|
MatrixRTCSessionManager,
|
||||||
} from "matrix-js-sdk/lib/matrixrtc";
|
} from "matrix-js-sdk/lib/matrixrtc";
|
||||||
import {
|
import {
|
||||||
type Room as LivekitRoom,
|
type Room as LivekitRoom,
|
||||||
@@ -87,25 +87,35 @@ export async function createMatrixRTCSdk(
|
|||||||
id: string = "",
|
id: string = "",
|
||||||
sticky: boolean = false,
|
sticky: boolean = false,
|
||||||
): Promise<MatrixRTCSdk> {
|
): Promise<MatrixRTCSdk> {
|
||||||
|
const scope = new ObservableScope();
|
||||||
|
|
||||||
|
// widget client
|
||||||
initializeWidget(application);
|
initializeWidget(application);
|
||||||
const widget = _widget;
|
const widget = _widget;
|
||||||
if (!widget) throw Error("No widget. This webapp can only start as a widget");
|
if (!widget) throw Error("No widget. This webapp can only start as a widget");
|
||||||
const client = await widget.client;
|
const client = await widget.client;
|
||||||
logger.info("client created");
|
logger.info("client created");
|
||||||
const scope = new ObservableScope();
|
|
||||||
|
// url params
|
||||||
const { roomId } = getUrlParams();
|
const { roomId } = getUrlParams();
|
||||||
if (roomId === null) throw Error("could not get roomId from url params");
|
if (roomId === null) throw Error("could not get roomId from url params");
|
||||||
|
|
||||||
const room = client.getRoom(roomId);
|
const room = client.getRoom(roomId);
|
||||||
if (room === null) throw Error("could not get room from client");
|
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 mediaDevices = new MediaDevices(scope);
|
||||||
const muteStates = new MuteStates(scope, mediaDevices, {
|
const muteStates = new MuteStates(scope, mediaDevices, {
|
||||||
audioEnabled: false,
|
audioEnabled: false,
|
||||||
videoEnabled: false,
|
videoEnabled: false,
|
||||||
});
|
});
|
||||||
const slot = { application, id };
|
|
||||||
const rtcSession = new MatrixRTCSession(client, room, slot);
|
// call view model
|
||||||
const callViewModel = createCallViewModel$(
|
const callViewModel = createCallViewModel$(
|
||||||
scope,
|
scope,
|
||||||
rtcSession,
|
rtcSession,
|
||||||
@@ -118,6 +128,7 @@ export async function createMatrixRTCSdk(
|
|||||||
constant({ supported: false, processor: undefined }),
|
constant({ supported: false, processor: undefined }),
|
||||||
);
|
);
|
||||||
logger.info("CallViewModelCreated");
|
logger.info("CallViewModelCreated");
|
||||||
|
|
||||||
// create data listener
|
// create data listener
|
||||||
const data$ = new Subject<{ sender: string; data: string }>();
|
const data$ = new Subject<{ sender: string; data: string }>();
|
||||||
|
|
||||||
|
|||||||
@@ -11454,7 +11454,7 @@ __metadata:
|
|||||||
|
|
||||||
"matrix-js-sdk@matrix-org/matrix-js-sdk#develop":
|
"matrix-js-sdk@matrix-org/matrix-js-sdk#develop":
|
||||||
version: 40.0.0
|
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:
|
dependencies:
|
||||||
"@babel/runtime": "npm:^7.12.5"
|
"@babel/runtime": "npm:^7.12.5"
|
||||||
"@matrix-org/matrix-sdk-crypto-wasm": "npm:^17.0.0"
|
"@matrix-org/matrix-sdk-crypto-wasm": "npm:^17.0.0"
|
||||||
@@ -11470,7 +11470,7 @@ __metadata:
|
|||||||
sdp-transform: "npm:^3.0.0"
|
sdp-transform: "npm:^3.0.0"
|
||||||
unhomoglyph: "npm:^1.0.6"
|
unhomoglyph: "npm:^1.0.6"
|
||||||
uuid: "npm:13"
|
uuid: "npm:13"
|
||||||
checksum: 10c0/9f97cec346e0dcce8599bc3afa1608f5166408260937f8311fa9af95b8fd2ff6d86422124fcb721fc830a3ec269389067334c344b4f512b64299561484135326
|
checksum: 10c0/9c6e9878d8ff42edb8761b63d398975592698d70d38548d5f27eca6cedfb599242e3a24c8503ff1f0edc326f62f640174291510670bc0cb9282e163800d6f916
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user