cleanup changes godot->sdk add docs

This commit is contained in:
Timo K
2025-12-01 14:05:41 +01:00
parent 0664af0f1b
commit 1490359e4c
12 changed files with 66 additions and 38 deletions

72
sdk/index.html Normal file
View File

@@ -0,0 +1,72 @@
<!doctype html>
<html>
<head>
<title>Godot MatrixRTC Widget</title>
<meta charset="utf-8" />
<script type="module">
// TODO use the url where the matrixrtc-sdk.js file from dist is hosted
import { createMatrixRTCSdk } from "http://localhost:8123/matrixrtc-sdk.js";
try {
console.log("Hello from index.html");
try {
window.matrixRTCSdk = await createMatrixRTCSdk();
console.info("createMatrixRTCSdk was created!");
} catch (e) {
console.error("createMatrixRTCSdk", e);
}
// const sdk = window.matrixRTCSdk;
console.info("matrixRTCSdk join ", window.matrixRTCSdk);
await window.matrixRTCSdk.join();
console.info("matrixRTCSdk joined ");
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>
<button onclick="window.matrixRTCSdk.leave();">Leave</button>
<button onclick="window.matrixRTCSdk.sendData({prop: 'Hello, world!'});">
Send Text
</button>
<div id="members"></div>
<div id="data"></div>
<canvas id="canvas"></canvas>
</body>
</html>