Skip to content

Commit f1a91b2

Browse files
committed
cleanup changes godot->sdk add docs
1 parent 0664af0 commit f1a91b2

File tree

12 files changed

+64
-38
lines changed

12 files changed

+64
-38
lines changed

godot/README.md

Lines changed: 0 additions & 14 deletions
This file was deleted.

godot/favicon.ico

-2.38 KB
Binary file not shown.

index.html

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,5 @@
4343
<% if (packageType !== "full") { %>
4444
<div id="root"></div>
4545
<% } %>
46-
47-
<!-- Godot export -->
48-
<% if (packageType === "godot") { %>
49-
<canvas id="canvas"></canvas>
50-
<script src="$GODOT_URL"></script>
51-
<script>
52-
var engine = new Engine($GODOT_CONFIG);
53-
engine.startGame();
54-
</script>
55-
<% } %>
5646
</body>
5747
</html>

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"build:embedded": "yarn build:full --config vite-embedded.config.js",
1414
"build:embedded:production": "yarn build:embedded",
1515
"build:embedded:development": "yarn build:embedded --mode development",
16-
"build:godot": "yarn build:full --config vite-godot.config.js",
17-
"build:godot:development": "yarn build:godot --mode development",
16+
"build:sdk": "yarn build:full --config vite-sdk.config.js",
17+
"build:sdk:development": "yarn build:sdk --mode development",
1818
"serve": "vite preview",
1919
"prettier:check": "prettier -c .",
2020
"prettier:format": "prettier -w .",

sdk/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# SDK mode
2+
EC can be build in sdk mode. This will result in a compiled js file that can be imported in very simple webapps.
3+
4+
It allows to use matrixRTC in combination with livekit without relying on element call.
5+
6+
This is done by instantiating the call view model and exposing some useful behaviors (observables) and methods.
7+
8+
This folder contains an example index.html file that showcases the sdk in use (hosted on localhost:8123 with a webserver ellowing cors (for example `npx serve -l 81234 --cors`)) as a godot engine HTML export template.
9+
10+
## Widgets
11+
The sdk mode is particularly interesting to be used in widgets where you do not need to pay attention to matrix login/cs api ...
12+
To create a widget see the example index.html file in this folder. And add it to EW via:
13+
`/addwidget <widgetUrl>` (see **url parameters** for more details on `<widgetUrl>`)
14+
15+
### url parameters
16+
```
17+
widgetId = $matrix_widget_id
18+
perParticipantE2EE = true
19+
userId = $matrix_user_id
20+
deviceId = $org.matrix.msc3819.matrix_device_id
21+
baseUrl = $org.matrix.msc4039.matrix_base_url
22+
```
23+
`
24+
parentUrl = // will be inserted automatically
25+
`
26+
27+
Full template use as `<widgetUrl>`:
28+
29+
```
30+
http://localhost:3000?widgetId=$matrix_widget_id&perParticipantE2EE=true&userId=$matrix_user_id&deviceId=$org.matrix.msc3819.matrix_device_id&baseUrl=$org.matrix.msc4039.matrix_base_url&roomId=$matrix_room_id
31+
```
32+
33+
the `$` prefixed variables will be replaced by EW on widget instantiation. (e.g. `$matrix_user_id` -> `@user:example.com` (url encoding will also be applied automatically by EW) -> `%40user%3Aexample.com`)

godot/helper.ts renamed to sdk/helper.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
55
Please see LICENSE in the repository root for full details.
66
*/
77

8+
/**
9+
* This file contains helper functions and types for the MatrixRTC SDK.
10+
*/
11+
812
import { logger as rootLogger } from "matrix-js-sdk/lib/logger";
913
import { scan } from "rxjs";
1014

godot/index.html renamed to sdk/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<title>Godot MatrixRTC Widget</title>
55
<meta charset="utf-8" />
66
<script type="module">
7-
// TODO use the url where the matrixrtc-ec-godot.js file from dist is hosted
8-
import { createMatrixRTCSdk } from "http://localhost:8123/matrixrtc-ec-godot.js";
7+
// TODO use the url where the matrixrtc-sdk.js file from dist is hosted
8+
import { createMatrixRTCSdk } from "http://localhost:8123/matrixrtc-sdk.js";
99

1010
try {
1111
console.log("Hello from index.html");

godot/main.ts renamed to sdk/main.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,19 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
55
Please see LICENSE in the repository root for full details.
66
*/
77

8-
// import { type InitResult } from "../src/ClientContext";
8+
/**
9+
* This file is the entrypoint for the sdk build of element call: `yarn build:sdk`
10+
* use in widgets.
11+
* It exposes the `createMatrixRTCSdk` which creates the `MatrixRTCSdk` interface (see below) that
12+
* can be used to join a rtc session and exchange realtime data.
13+
* It takes care of all the tricky bits:
14+
* - sending delayed events
15+
* - finding the right sfu
16+
* - handling the media stream
17+
* - sending join/leave state or sticky events
18+
* - setting up encryption and scharing keys
19+
*/
20+
921
import { map, type Observable, of, Subject, switchMap, tap } from "rxjs";
1022
import { MatrixRTCSessionEvent } from "matrix-js-sdk/lib/matrixrtc";
1123
import { type TextStreamInfo } from "livekit-client/dist/src/room/types";
@@ -40,6 +52,7 @@ interface MatrixRTCSdk {
4052
members$: Behavior<MatrixLivekitMember[]>;
4153
sendData?: (data: unknown) => Promise<void>;
4254
}
55+
4356
export async function createMatrixRTCSdk(): Promise<MatrixRTCSdk> {
4457
logger.info("Hello");
4558
const client = await widget.client;

src/state/CallViewModel/CallViewModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ export interface CallViewModel {
262262
participantCount$: Behavior<number>;
263263
/** Participants sorted by livekit room so they can be used in the audio rendering */
264264
livekitRoomItems$: Behavior<LivekitRoomItem[]>;
265-
/** use the layout instead, this is just for the godot export. */
266265
userMedia$: Behavior<UserMedia[]>;
266+
/** use the layout instead, this is just for the sdk export. */
267267
matrixLivekitMembers$: Behavior<MatrixLivekitMember[]>;
268268
localMatrixLivekitMember$: Behavior<LocalMatrixLivekitMember | null>;
269269
/** List of participants raising their hand */

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"./src/**/*.ts",
5555
"./src/**/*.tsx",
5656
"./playwright/**/*.ts",
57-
"./godot/**/*.ts"
57+
"./sdk/**/*.ts"
5858
],
5959
"exclude": ["**.test.ts"]
6060
}

0 commit comments

Comments
 (0)