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