32 lines
656 B
JavaScript
32 lines
656 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
|
|
startSteps();
|
|
}
|
|
};
|
|
|
|
function requestNextProblem() {
|
|
socket.send(JSON.stringify({
|
|
type: "query_problem"
|
|
}));
|
|
} |