bug fixes

This commit is contained in:
2025-08-25 18:36:59 -04:00
parent a117f6703f
commit 6c45e7b114
5 changed files with 78 additions and 39 deletions

View File

@@ -74,33 +74,38 @@ const api = new Elysia({ prefix: "/api" })
},
send,
}) {
const table = liveTable<
SimpleConfiguration,
SimpleGameState,
SimpleAction
>(tableKey);
console.log(humanKey, "connected");
try {
const table = liveTable<
SimpleConfiguration,
SimpleGameState,
SimpleAction
>(tableKey);
table.outputs.playersPresent.onValue((players) =>
send({ players })
);
table.outputs.playersPresent.onValue((players) =>
send({ players })
);
table.outputs.playersReady.onValue((readys) =>
send({ playersReady: readys })
);
table.outputs.playersReady.onValue((readys) =>
send({ playersReady: readys })
);
combine(
[table.outputs.gameState],
[table.outputs.gameConfig],
(state, config) =>
state &&
config &&
getSimplePlayerView(config, state, humanKey)
).onValue((view) => send({ view }));
combine(
[table.outputs.gameState],
[table.outputs.gameConfig],
(state, config) =>
state &&
config &&
getSimplePlayerView(config, state, humanKey)
).onValue((view) => send({ view }));
table.inputs.connectionChanges.emit({
humanKey,
presence: "joined",
});
table.inputs.connectionChanges.emit({
humanKey,
presence: "joined",
});
} catch (err) {
console.error(err);
}
},
response: WsOut,
@@ -139,6 +144,10 @@ const api = new Elysia({ prefix: "/api" })
presence: "left",
});
},
// error(err) {
// console.error("ERROR IN WEBSOCKET", JSON.stringify(err, null, 2));
// },
});
export default api;