fixed delayed WS bug

This commit is contained in:
MathMan05 2024-07-30 21:04:23 -05:00
parent ebea3af112
commit fb4721196b
2 changed files with 36 additions and 19 deletions

View file

@ -157,16 +157,24 @@ class Localuser {
w.write(arr.buffer);
arr = new Uint8Array();
//console.log(data,test);
const read = (await r.read());
const data = new TextDecoder().decode(read.value);
build += data;
console.log("temp");
try {
temp = JSON.parse(build);
build = "";
}
catch {
return;
while (true) {
const read = (await r.read());
const data = new TextDecoder().decode(read.value);
if (data === "") {
break;
}
build += data;
console.log("temp");
try {
temp = JSON.parse(build);
build = "";
if (temp.op === 0 && temp.t === "READY") {
returny();
}
this.handleEvent(temp);
}
catch {
}
}
}
else {