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