Skip to content

Commit

Permalink
sim: bsod on watcher disconnect (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
JerwuQu authored May 12, 2024
1 parent 5135465 commit 17781ae
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions simulator/src/ui/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,20 @@ export class App extends LitElement {
}
});

let wsWasConnected = false
const ws = new WebSocket(`ws://localhost:2468/ws`);
ws.onopen = w => {
ws.onopen = () => {
wsWasConnected = true;
setInterval(() => {
ws.send("spam");
}, 100);
}

ws.onclose = () => {
if (wsWasConnected) {
wsWasConnected = false;
runtime.blueScreen("Watcher was\ndisconnected.");
}
};
ws.onmessage = async m => {
if (m.data == "reload") {
await this.resetCart(new Uint8Array(await (await fetch("http://localhost:2468/cart.wasm")).arrayBuffer()), false);
Expand Down

0 comments on commit 17781ae

Please sign in to comment.