diff --git a/client/svelte-client/src/components/NetworkSessionWrapper.svelte b/client/svelte-client/src/components/NetworkSessionWrapper.svelte
index a68dceb..3440d9f 100644
--- a/client/svelte-client/src/components/NetworkSessionWrapper.svelte
+++ b/client/svelte-client/src/components/NetworkSessionWrapper.svelte
@@ -1,8 +1,8 @@
{#if !session}
diff --git a/client/svelte-client/src/store/session.ts b/client/svelte-client/src/store/session.ts
index a81414a..3b89cf4 100644
--- a/client/svelte-client/src/store/session.ts
+++ b/client/svelte-client/src/store/session.ts
@@ -47,11 +47,6 @@ const player2KeyboardInputs = derived(
}
)
-export type NetworkEventStore = {
- subscribe: any,
- produce: (snapshot: SessionSnapshot) => void
-}
-
function createNetworkEvents() {
const {subscribe, set, update} = writable([]);
@@ -94,6 +89,9 @@ function createNetworkEvents() {
function produce(sessionSnapshot: SessionSnapshot) {
const ws = get(websocket);
+ if (!ws) {
+ return;
+ }
console.debug("producing snapshot to ws: ", sessionSnapshot);
ws.send(JSON.stringify(sessionSnapshot));
}
@@ -110,7 +108,7 @@ function createNetworkEvents() {
}
}
-const networkEvents = createNetworkEvents();
+export const networkEvents = createNetworkEvents();
// TODO: Use websocket to write snapshots.