mirror of
https://github.com/vector-im/element-call.git
synced 2026-03-04 05:37:22 +00:00
log cleanup and expose members$
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
<title>Godot MatrixRTC Widget</title>
|
||||
<meta charset="utf-8" />
|
||||
<script type="module">
|
||||
// TODO use the url where the matrixrtc-ec-godot.js file from dist is hosted
|
||||
import { createMatrixRTCSdk } from "http://localhost:8123/matrixrtc-ec-godot.js";
|
||||
|
||||
try {
|
||||
@@ -20,18 +21,43 @@
|
||||
await window.matrixRTCSdk.join();
|
||||
console.info("matrixRTCSdk joined ");
|
||||
|
||||
// window.matrixRTCSdk.data$.subscribe((data) => {
|
||||
// console.log(data);
|
||||
// const div = document.getElementById("data");
|
||||
// div.appendChild(document.createTextNode(data));
|
||||
// // TODO forward to godot
|
||||
// });
|
||||
const div = document.getElementById("data");
|
||||
div.innerHTML = "<h3>Data:</h3>";
|
||||
|
||||
window.matrixRTCSdk.data$.subscribe((data) => {
|
||||
const child = document.createElement("p");
|
||||
child.innerHTML = JSON.stringify(data);
|
||||
div.appendChild(child);
|
||||
// TODO forward to godot
|
||||
});
|
||||
|
||||
window.matrixRTCSdk.members$.subscribe((memberObjects) => {
|
||||
console.info("members changed", memberObjects);
|
||||
|
||||
// reset div
|
||||
const div = document.getElementById("members");
|
||||
div.innerHTML = "<h3>Members:</h3>";
|
||||
|
||||
// create member list
|
||||
const members = memberObjects.map((member) => member.userId);
|
||||
console.info("members changed", members);
|
||||
for (const m of members) {
|
||||
console.info("member", m);
|
||||
const child = document.createElement("p");
|
||||
child.innerHTML = m;
|
||||
div.appendChild(child);
|
||||
}
|
||||
// TODO forward to godot
|
||||
});
|
||||
|
||||
// TODO use it as godot HTML template
|
||||
// var engine = new Engine($GODOT_CONFIG);
|
||||
// engine.startGame();
|
||||
} catch (e) {
|
||||
console.error("catchALL,", e);
|
||||
}
|
||||
</script>
|
||||
<!--// TODO use it as godot HTML template-->
|
||||
<!--<script src="$GODOT_URL"></script>-->
|
||||
</head>
|
||||
<body>
|
||||
@@ -39,6 +65,7 @@
|
||||
<button onclick="window.matrixRTCSdk.sendData({prop: 'Hello, world!'});">
|
||||
Send Text
|
||||
</button>
|
||||
<div id="members"></div>
|
||||
<div id="data"></div>
|
||||
<canvas id="canvas"></canvas>
|
||||
</body>
|
||||
|
||||
@@ -30,12 +30,14 @@ import {
|
||||
widget,
|
||||
} from "./helper";
|
||||
import { ElementWidgetActions } from "../src/widget";
|
||||
import { type MatrixLivekitMember } from "../src/state/CallViewModel/remoteMembers/MatrixLivekitMembers";
|
||||
|
||||
interface MatrixRTCSdk {
|
||||
join: () => LocalMemberConnectionState;
|
||||
/** @throws on leave errors */
|
||||
leave: () => void;
|
||||
data$: Observable<{ sender: string; data: string }>;
|
||||
members$: Behavior<MatrixLivekitMember[]>;
|
||||
sendData?: (data: unknown) => Promise<void>;
|
||||
}
|
||||
export async function createMatrixRTCSdk(): Promise<MatrixRTCSdk> {
|
||||
@@ -143,7 +145,7 @@ export async function createMatrixRTCSdk(): Promise<MatrixRTCSdk> {
|
||||
// create sendData function
|
||||
const sendFn: Behavior<(data: string) => Promise<TextStreamInfo>> =
|
||||
scope.behavior(
|
||||
callViewModel.localmatrixLivekitMembers$.pipe(
|
||||
callViewModel.localMatrixLivekitMember$.pipe(
|
||||
switchMap((m) => {
|
||||
if (!m)
|
||||
return of((data: string): never => {
|
||||
@@ -223,6 +225,7 @@ export async function createMatrixRTCSdk(): Promise<MatrixRTCSdk> {
|
||||
livekitRoomItemsSub.unsubscribe();
|
||||
},
|
||||
data$,
|
||||
members$: callViewModel.matrixLivekitMembers$,
|
||||
sendData,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -264,7 +264,8 @@ export interface CallViewModel {
|
||||
livekitRoomItems$: Behavior<LivekitRoomItem[]>;
|
||||
/** use the layout instead, this is just for the godot export. */
|
||||
userMedia$: Behavior<UserMedia[]>;
|
||||
localmatrixLivekitMembers$: Behavior<LocalMatrixLivekitMember | null>;
|
||||
matrixLivekitMembers$: Behavior<MatrixLivekitMember[]>;
|
||||
localMatrixLivekitMember$: Behavior<LocalMatrixLivekitMember | null>;
|
||||
/** List of participants raising their hand */
|
||||
handsRaised$: Behavior<Record<string, RaisedHandInfo>>;
|
||||
/** List of reactions. Keys are: membership.membershipId (currently predefined as: `${membershipEvent.userId}:${membershipEvent.deviceId}`)*/
|
||||
@@ -446,7 +447,7 @@ export function createCallViewModel$(
|
||||
},
|
||||
),
|
||||
),
|
||||
logger: logger,
|
||||
logger,
|
||||
});
|
||||
|
||||
const { matrixLivekitMembers$ } = createMatrixLivekitMembers$({
|
||||
@@ -488,6 +489,9 @@ export function createCallViewModel$(
|
||||
mediaDevices,
|
||||
muteStates,
|
||||
trackProcessorState$,
|
||||
logger.getChild(
|
||||
"[Publisher " + connection.transport.livekit_service_url + "]",
|
||||
),
|
||||
);
|
||||
},
|
||||
connectionManager: connectionManager,
|
||||
@@ -515,7 +519,7 @@ export function createCallViewModel$(
|
||||
userId: userId,
|
||||
};
|
||||
|
||||
const localmatrixLivekitMembers$: Behavior<LocalMatrixLivekitMember | null> =
|
||||
const localMatrixLivekitMember$: Behavior<LocalMatrixLivekitMember | null> =
|
||||
scope.behavior(
|
||||
localRtcMembership$.pipe(
|
||||
switchMap((membership) => {
|
||||
@@ -685,7 +689,7 @@ export function createCallViewModel$(
|
||||
*/
|
||||
const userMedia$ = scope.behavior<UserMedia[]>(
|
||||
combineLatest([
|
||||
localmatrixLivekitMembers$,
|
||||
localMatrixLivekitMember$,
|
||||
matrixLivekitMembers$,
|
||||
duplicateTiles.value$,
|
||||
]).pipe(
|
||||
@@ -1518,7 +1522,16 @@ export function createCallViewModel$(
|
||||
pip$: pip$,
|
||||
layout$: layout$,
|
||||
userMedia$,
|
||||
localmatrixLivekitMembers$,
|
||||
localMatrixLivekitMember$,
|
||||
matrixLivekitMembers$: scope.behavior(
|
||||
matrixLivekitMembers$.pipe(
|
||||
// TODO flatten this so its not a obs of obs.
|
||||
map((members) => members.value),
|
||||
tap((v) => {
|
||||
logger.debug("matrixLivekitMembers$ updated (exported)", v);
|
||||
}),
|
||||
),
|
||||
),
|
||||
tileStoreGeneration$: tileStoreGeneration$,
|
||||
showSpotlightIndicators$: showSpotlightIndicators$,
|
||||
showSpeakingIndicators$: showSpeakingIndicators$,
|
||||
|
||||
@@ -58,7 +58,7 @@ export class Publisher {
|
||||
trackerProcessorState$: Behavior<ProcessorState>,
|
||||
private logger: Logger,
|
||||
) {
|
||||
this.logger.info("[PublishConnection] Create LiveKit room");
|
||||
this.logger.info("Create LiveKit room");
|
||||
const { controlledAudioDevices } = getUrlParams();
|
||||
|
||||
const room = connection.livekitRoom;
|
||||
@@ -74,9 +74,7 @@ export class Publisher {
|
||||
|
||||
this.workaroundRestartAudioInputTrackChrome(devices, scope);
|
||||
this.scope.onEnd(() => {
|
||||
this.logger.info(
|
||||
"[PublishConnection] Scope ended -> stop publishing all tracks",
|
||||
);
|
||||
this.logger.info("Scope ended -> stop publishing all tracks");
|
||||
void this.stopPublishing();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
type BaseKeyProvider,
|
||||
} from "livekit-client";
|
||||
import { type Logger } from "matrix-js-sdk/lib/logger";
|
||||
// imported as inline to support worker when loaded from a cdn (cross domain)
|
||||
import E2EEWorker from "livekit-client/e2ee-worker?worker&inline";
|
||||
|
||||
import { type ObservableScope } from "../../ObservableScope.ts";
|
||||
|
||||
Reference in New Issue
Block a user