[wip] gameplay works but config not respected

This commit is contained in:
2025-09-07 23:31:19 -04:00
parent ae6a79aadd
commit ed42c831de

View File

@@ -1,6 +1,6 @@
import type { TWsIn, TWsOut } from "@games/server/src/table";
import games from "@games/shared/games/index";
import { fromPromise, pool, Property, Stream } from "kefir";
import { pool, Property, Stream } from "kefir";
import {
Accessor,
createContext,
@@ -43,8 +43,10 @@ export const TableContext = createContext<{
export default (props: { tableKey: string }) => {
// #region Websocket declaration
let ws: ReturnType<ReturnType<typeof api.ws>["subscribe"]> | undefined =
undefined;
const wsEvents = pool<TWsOut, any>();
let sendWs: (msg: TWsIn) => void = () => {};
const sendWs = (msg: TWsIn) => ws?.send(msg);
// #endregion
@@ -88,15 +90,14 @@ export default (props: { tableKey: string }) => {
const [ready, setReady] = createSignal(false);
onMount(() => {
const ws = api.ws(props).subscribe();
ws = api.ws(props).subscribe();
ws.on("open", () => {
wsEvents.plug(fromWebsocket<TWsOut>(ws));
sendWs = ws.send.bind(ws);
createEffect(() => sendWs({ ready: ready() }));
createEffect(() => sendWs({ name: name() }));
});
onCleanup(() => ws.close());
onCleanup(() => ws?.close());
});
const GamePicker = () => {