YARN-9091. Improve terminal message when connection is refused. Contributed by Eric Yang

This commit is contained in:
Billie Rinaldi 2018-12-14 19:55:50 -08:00
parent 42297f7d99
commit 4f622337ee
1 changed files with 14 additions and 0 deletions

View File

@ -87,11 +87,25 @@
if (user != null) {
url = url + "?user.name=" + encodeURI(user);
}
document.title = getQueryVariable("container");
console.log(url);
var sock = new WebSocket(url);
sock.addEventListener('open', function () {
term.attach(sock, true, true);
});
sock.addEventListener('close', function(event) {
switch(event.code) {
case 1000:
term.write('Remote Connection closed.');
break;
case 1008:
term.write('Remote Connection refused.');
break;
case 1001:
term.write('Remote Connection going away.');
break;
}
});
term.open(container);
term.winptyCompatInit();
term.fit();