diff --git a/frontend/src/routes/stream/Stream.svelte b/frontend/src/routes/stream/Stream.svelte
index bf1560d..311fa95 100644
--- a/frontend/src/routes/stream/Stream.svelte
+++ b/frontend/src/routes/stream/Stream.svelte
@@ -12,13 +12,19 @@
let loading = $state(true);
let fullscreen = $state(false);
let gameplayView: HTMLDivElement;
+ let gameplayCanvas: HTMLCanvasElement;
async function startStream() {
console.log(`Connecting to stream at ${url} with cert_hash ${certHash}`);
- await streamUrl(url, certHash);
+ await streamUrl(url, certHash, gameplayCanvas);
}
async function requestFullscreen() {
+ // Update fullscreen var if fullscreen was exited outside our control
+ if (document.fullscreenElement == null) {
+ fullscreen = false;
+ }
+
if (fullscreen) {
await document.exitFullscreen();
fullscreen = false;
@@ -36,7 +42,7 @@
-
+
diff --git a/frontend/src/routes/stream/stream.ts b/frontend/src/routes/stream/stream.ts
index d447fcc..7423171 100644
--- a/frontend/src/routes/stream/stream.ts
+++ b/frontend/src/routes/stream/stream.ts
@@ -26,92 +26,89 @@ type DecodeUnitPacket = {
DecodeUnit: DecodeUnit
}
+async function connectToUrl(url: string, certHash: Uint8Array): Promise {
+ console.log('Hash: ', certHash);
+ console.log(`Connecting to stream`);
+ // Check if WebTransport is supported
+ if (!window.WebTransport) {
+ throw new Error('WebTransport is not supported in this browser');
+ }
-export async function streamUrl(url: string, cert_hash: Array) {
- const buffer = new Uint8Array(cert_hash);
- console.log('Hash: ', buffer);
- try {
- console.log(`Connecting to stream`);
-
- // Check if WebTransport is supported
- if (!window.WebTransport) {
- throw new Error('WebTransport is not supported in this browser');
- }
-
- //const url = new URL();
- const transport = new WebTransport(url, {
- serverCertificateHashes: [
- {
- algorithm: "sha-256",
- value: buffer,
- }
- ]
- });
-
- console.log('Connecting to WebTransport at ', url);
- // Wait for the connection to be ready
- await transport.ready;
- console.log('WebTransport connection established');
-
-
- console.log('Creating WebTransport bidirectional stream');
- const stream = await transport.createBidirectionalStream();
- console.log('Bidirectional stream created');
-
- const reader = stream.readable.getReader();
-
- function parseData(newBuffer: Uint8Array, oldBuffer: Uint8Array): [Array