Files
Youtube_Math/www/scripts/web_sockets.js
2026-05-02 19:26:17 -04:00

32 lines
659 B
JavaScript

//const socket = new WebSocket("ws://localhost:8000/ws");
const socket = new WebSocket("ws://10.0.0.50: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"
}));
}