Websocket error messages and misc.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3804 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2022-01-29 20:43:19 +00:00
parent d062db2ba8
commit 40216377f9
3 changed files with 21 additions and 4 deletions

View File

@ -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);
}
}
}