From 40216377f9351c71d1091070ad5c7f52dad3f24c Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sat, 29 Jan 2022 20:43:19 +0000 Subject: [PATCH] Websocket error messages and misc. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3804 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/cory/index.json | 2 +- apps/cory/index/index.html | 2 +- core/client.js | 21 +++++++++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/apps/cory/index.json b/apps/cory/index.json index 339e6577..dd31bb4c 100644 --- a/apps/cory/index.json +++ b/apps/cory/index.json @@ -1 +1 @@ -{"type":"tildefriends-app","files":{"app.js":"&OOcUHSIAA6CR2dYSv2BwOMBZ1hjFg+PJZPABhZMe1Gc=.sha256","index.html":"&vAy6mHSTMNDHo2P9CuRbsi0FMRtbOXXOP/2JbfGiZMU=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&3dPiSNYjoJE3zn1oTT1SBhbvkW9MHr7ZUDxUJiBI1Ss=.sha256","tf.js":"&/yKh5E/PLaK/M3tivdldiEDnpeYQYyuLHWjjdM/QpxE=.sha256","commonmark.min.js":"&EP0OeR9zyLwZannz+0ga4s9AGES2RLvvIIQYHqqV6+k=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256","tf-shared.js":"&+qPP3g4CAUlkt8K4iBCZ+F5Fy6N7fu6MggvSVss2juE=.sha256"}} \ No newline at end of file +{"type":"tildefriends-app","files":{"app.js":"&OOcUHSIAA6CR2dYSv2BwOMBZ1hjFg+PJZPABhZMe1Gc=.sha256","index.html":"&ko7qv1Ihzmw8ibXr0RinyzNBc2xNzcGDQDPO9X3JAAQ=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&3dPiSNYjoJE3zn1oTT1SBhbvkW9MHr7ZUDxUJiBI1Ss=.sha256","tf.js":"&/yKh5E/PLaK/M3tivdldiEDnpeYQYyuLHWjjdM/QpxE=.sha256","commonmark.min.js":"&EP0OeR9zyLwZannz+0ga4s9AGES2RLvvIIQYHqqV6+k=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256","tf-shared.js":"&+qPP3g4CAUlkt8K4iBCZ+F5Fy6N7fu6MggvSVss2juE=.sha256"}} \ No newline at end of file diff --git a/apps/cory/index/index.html b/apps/cory/index/index.html index 83d6ba3f..6c2a9086 100644 --- a/apps/cory/index/index.html +++ b/apps/cory/index/index.html @@ -65,7 +65,7 @@
- + diff --git a/core/client.js b/core/client.js index 6bee01f1..cf03978d 100644 --- a/core/client.js +++ b/core/client.js @@ -435,7 +435,7 @@ function receive(message) { var iframe = document.getElementById("document"); iframe.contentWindow.postMessage(message.message, "*"); } else if (message && message.action == "ping") { - gSocket.send(JSON.stringify({action: "pong"})); + send({action: "pong"}); } else if (message && message.action == "error") { if (message.error) { if (typeof(message.error) == 'string') { @@ -701,7 +701,24 @@ function connectSocket(path) { receive(JSON.parse(event.data)); } gSocket.onclose = function(event) { - setStatusMessage("Connection closed with code " + event.code, kErrorColor); + const k_codes = { + 1000: 'Normal closure', + 1001: 'Going away', + 1002: 'Protocol error', + 1003: 'Unsupported data', + 1005: 'No status received', + 1006: 'Abnormal closure', + 1007: 'Invalid frame payload data', + 1008: 'Policy violation', + 1009: 'Message too big', + 1010: 'Missing extension', + 1011: 'Internal error', + 1012: 'Service restart', + 1013: 'Try again later', + 1014: 'Bad gateway', + 1015: 'TLS handshake', + }; + setStatusMessage("Connection closed: " + (k_codes[event.code] || event.code), kErrorColor); } } }