diff --git a/components/conceptHeader.vue b/components/conceptHeader.vue
index 047edf1..f55dd71 100644
--- a/components/conceptHeader.vue
+++ b/components/conceptHeader.vue
@@ -10,7 +10,6 @@ const currentGames = computed(() => {
const games = Object.values(lobbyStore.games).filter((g) =>
g.players.some((p) => p.user.id == userStore.self?.id)
);
- console.log(games);
return games;
});
diff --git a/netcode/events b/netcode/events
index 49adbde..e9d5d8d 160000
--- a/netcode/events
+++ b/netcode/events
@@ -1 +1 @@
-Subproject commit 49adbdec5b00604e725d1809a36a8bb94d4e9576
+Subproject commit e9d5d8d909e4ba952f6bed53ead08642466431d1
diff --git a/netcode/handlers/game.handler.ts b/netcode/handlers/game.handler.ts
new file mode 100644
index 0000000..38acab1
--- /dev/null
+++ b/netcode/handlers/game.handler.ts
@@ -0,0 +1,3 @@
+export const handlers = {
+ join: (event: any) => {},
+};
diff --git a/pages/game/[id].vue b/pages/game/[id].vue
index 773d3dd..b25e1be 100644
--- a/pages/game/[id].vue
+++ b/pages/game/[id].vue
@@ -1 +1,18 @@
-Hello
+
+
+{{ game }}
diff --git a/store/game.store.ts b/store/game.store.ts
new file mode 100644
index 0000000..ed62d6c
--- /dev/null
+++ b/store/game.store.ts
@@ -0,0 +1,41 @@
+import { defineStore } from "pinia";
+import { subscribe } from "~/netcode";
+import { GameResponseDTO } from "~/netcode/events/dto/gameresponse.dto";
+import { handlers } from "~/netcode/handlers/game.handler";
+
+export const useGameStore = defineStore("game", {
+ state: () => ({
+ game: null as null | GameResponseDTO,
+ eventSource: null as null | EventSource,
+ }),
+ actions: {
+ async subscribe(id: number) {
+ this.eventSource = subscribe(`/games/${id}/subscribe`);
+ this.eventSource.addEventListener("message", async (message) => {
+ const data = JSON.parse(message.data);
+ const type = data.type as string;
+ if (type in handlers) {
+ handlers[type as keyof typeof handlers](data);
+ }
+ });
+ },
+ async close() {
+ this.eventSource?.close();
+ },
+ async fetchGame(id: number) {
+ const config = useRuntimeConfig();
+ const data = await useFetch(
+ config.public.endpoint + `/games/` + id,
+ {
+ credentials: "include",
+ immediate: true,
+ }
+ );
+ if (data.data.value) {
+ this.game = data.data.value;
+ }
+
+ return data.data;
+ },
+ },
+});