Added Websocket stuff

This commit is contained in:
2026-05-02 18:26:02 -04:00
parent 7f49abd5e1
commit f34125d67b
10 changed files with 140 additions and 102 deletions

View File

@@ -0,0 +1,31 @@
const socket = new WebSocket("ws://localhost:8000/ws");
let problemData = null;
let stepIndex = 0;
socket.onopen = () => {
console.log("Connected to server");
socket.send(JSON.stringify({
type: "query_problem"
}));
};
socket.onmessage = (event) => {
const msg = JSON.parse(event.data);
if (msg.type === "generated_problem") {
problemData = msg.data;
stepIndex = 0;
showProblem();
// start animation sequence
startSequence();
}
};
function requestNextProblem() {
socket.send(JSON.stringify({
type: "query_problem"
}));
}