aboutsummaryrefslogtreecommitdiff
path: root/webAO/client.js
diff options
context:
space:
mode:
authoroldmud0 <oldmud0@users.noreply.github.com>2018-05-22 23:29:03 -0500
committeroldmud0 <oldmud0@users.noreply.github.com>2018-05-22 23:29:03 -0500
commit41d166c7912048fe1bdbf186fb68b9fc617ae2f1 (patch)
treecbe936114899c456c3ce7dcdd16a35f509679465 /webAO/client.js
parent3ac1870877eccf2b8fe40a28bf3807620ac94907 (diff)
Improve connection error dialog
Diffstat (limited to 'webAO/client.js')
-rw-r--r--webAO/client.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/webAO/client.js b/webAO/client.js
index f75970d..89baeff 100644
--- a/webAO/client.js
+++ b/webAO/client.js
@@ -187,8 +187,11 @@ class Client {
*/
onClose(e) {
console.error(`The connection was closed: ${e.reason} (${e.code})`);
- document.getElementById("client_error").style.display = "block";
- this.cleanup();
+ if (e.code !== 1001) {
+ document.getElementById("client_error").style.display = "block";
+ document.getElementById("error_id").textContent = e.code;
+ this.cleanup();
+ }
}
/**
@@ -216,10 +219,12 @@ class Client {
onError(e) {
console.error(`A network error occurred: ${e.reason} (${e.code})`);
document.getElementById("client_error").style.display = "block";
+ document.getElementById("error_id").textContent = e.code;
this.cleanup();
}
cleanup() {
+ this.serv.close(1001);
clearInterval(this.checkUpdater);
}
@@ -906,6 +911,7 @@ function changeBackground(position) {
* Triggered when the reconnect button is pushed.
*/
export function ReconnectButton() {
+ client.cleanup();
client = new Client(serverIP);
if (client) {
mode = "join"; // HACK: see client.onOpen