when in doubt make it a property I guess
This commit is contained in:
@@ -74,38 +74,35 @@ const api = new Elysia({ prefix: "/api" })
|
||||
},
|
||||
send,
|
||||
}) {
|
||||
console.log(humanKey, "connected");
|
||||
try {
|
||||
const table = liveTable<
|
||||
SimpleConfiguration,
|
||||
SimpleGameState,
|
||||
SimpleAction
|
||||
>(tableKey);
|
||||
const table = liveTable<
|
||||
SimpleConfiguration,
|
||||
SimpleGameState,
|
||||
SimpleAction
|
||||
>(tableKey);
|
||||
|
||||
table.outputs.playersPresent.onValue((players) =>
|
||||
send({ players })
|
||||
);
|
||||
table.inputs.connectionChanges.emit({
|
||||
humanKey,
|
||||
presence: "joined",
|
||||
});
|
||||
|
||||
table.outputs.playersReady.onValue((readys) =>
|
||||
send({ playersReady: readys })
|
||||
);
|
||||
table.outputs.playersPresent.onValue((players) =>
|
||||
send({ players })
|
||||
);
|
||||
|
||||
combine(
|
||||
[table.outputs.gameState],
|
||||
[table.outputs.gameConfig],
|
||||
(state, config) =>
|
||||
state &&
|
||||
config &&
|
||||
getSimplePlayerView(config, state, humanKey)
|
||||
).onValue((view) => send({ view }));
|
||||
table.outputs.playersReady.onValue((readys) =>
|
||||
send({ playersReady: readys })
|
||||
);
|
||||
|
||||
table.inputs.connectionChanges.emit({
|
||||
humanKey,
|
||||
presence: "joined",
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
combine(
|
||||
[table.outputs.gameState],
|
||||
[table.outputs.gameConfig],
|
||||
(state, config) =>
|
||||
state &&
|
||||
config &&
|
||||
getSimplePlayerView(config, state, humanKey)
|
||||
)
|
||||
.toProperty()
|
||||
.onValue((view) => send({ view }));
|
||||
},
|
||||
|
||||
response: WsOut,
|
||||
@@ -144,10 +141,6 @@ const api = new Elysia({ prefix: "/api" })
|
||||
presence: "left",
|
||||
});
|
||||
},
|
||||
|
||||
// error(err) {
|
||||
// console.error("ERROR IN WEBSOCKET", JSON.stringify(err, null, 2));
|
||||
// },
|
||||
});
|
||||
|
||||
export default api;
|
||||
|
||||
Reference in New Issue
Block a user