parent
2810fe248f
commit
3999dd3012
2 changed files with 8 additions and 1 deletions
|
@ -98,6 +98,10 @@ function readUrl(urlString) {
|
||||||
},
|
},
|
||||||
|
|
||||||
async onDisconnect() {
|
async onDisconnect() {
|
||||||
|
if (session.errored) return; // Display the error screen
|
||||||
|
|
||||||
|
console.info("showing disconnected refresh screen");
|
||||||
|
|
||||||
let duration = 5000 + Math.random() * 1000;
|
let duration = 5000 + Math.random() * 1000;
|
||||||
while (true) {
|
while (true) {
|
||||||
console.info("waiting a bit for the server to come back up", duration);
|
console.info("waiting a bit for the server to come back up", duration);
|
||||||
|
|
|
@ -81,6 +81,7 @@ class Session extends EventTarget {
|
||||||
super();
|
super();
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.secret = secret;
|
this.secret = secret;
|
||||||
|
this.errored = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async #recvJson() {
|
async #recvJson() {
|
||||||
|
@ -106,6 +107,7 @@ class Session extends EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
#dispatchError(source, kind, message) {
|
#dispatchError(source, kind, message) {
|
||||||
|
this.errored = true;
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
Object.assign(new Event("error"), {
|
Object.assign(new Event("error"), {
|
||||||
source,
|
source,
|
||||||
|
@ -123,7 +125,7 @@ class Session extends EventTarget {
|
||||||
|
|
||||||
this.ws.addEventListener("error", (event) => {
|
this.ws.addEventListener("error", (event) => {
|
||||||
console.error("WebSocket connection error", error);
|
console.error("WebSocket connection error", error);
|
||||||
this.dispatchEvent(Object.assign(new Event("error"), event));
|
this.#dispatchError(event, "ws", "WebSocket connection error");
|
||||||
});
|
});
|
||||||
|
|
||||||
this.ws.addEventListener("message", (event) => {
|
this.ws.addEventListener("message", (event) => {
|
||||||
|
@ -288,6 +290,7 @@ class Session extends EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
sendViewport({ left, top, right, bottom }) {
|
sendViewport({ left, top, right, bottom }) {
|
||||||
|
console.trace({ left, top, right, bottom });
|
||||||
this.#sendJson({
|
this.#sendJson({
|
||||||
request: "viewport",
|
request: "viewport",
|
||||||
topLeft: { x: left, y: top },
|
topLeft: { x: left, y: top },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue