|
|
|
@ -1615,16 +1615,21 @@ var Conn = (function() { |
|
|
|
|
var pingIv; |
|
|
|
|
var xoff = false; |
|
|
|
|
var autoXoffTout; |
|
|
|
|
var reconTout; |
|
|
|
|
|
|
|
|
|
var pageShown = false; |
|
|
|
|
|
|
|
|
|
function onOpen(evt) { |
|
|
|
|
console.log("CONNECTED"); |
|
|
|
|
doSend("i"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function onClose(evt) { |
|
|
|
|
console.warn("SOCKET CLOSED, code " + evt.code + ". Reconnecting..."); |
|
|
|
|
setTimeout(function() { |
|
|
|
|
clearTimeout(reconTout); |
|
|
|
|
reconTout = setTimeout(function () { |
|
|
|
|
init(); |
|
|
|
|
}, 200); |
|
|
|
|
}, 2000); |
|
|
|
|
// this happens when the buffer gets fucked up via invalid unicode.
|
|
|
|
|
// we basically use polling instead of socket then
|
|
|
|
|
} |
|
|
|
@ -1637,12 +1642,18 @@ var Conn = (function() { |
|
|
|
|
case 'T': |
|
|
|
|
case 'S': |
|
|
|
|
Screen.load(evt.data); |
|
|
|
|
if(!pageShown) { |
|
|
|
|
showPage(); |
|
|
|
|
pageShown = true; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case '-': |
|
|
|
|
//console.log('xoff');
|
|
|
|
|
xoff = true; |
|
|
|
|
autoXoffTout = setTimeout(function(){xoff=false;}, 250); |
|
|
|
|
autoXoffTout = setTimeout(function () { |
|
|
|
|
xoff = false; |
|
|
|
|
}, 250); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case '+': |
|
|
|
@ -1691,24 +1702,16 @@ var Conn = (function() { |
|
|
|
|
showPage(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
heartbeat(); |
|
|
|
|
|
|
|
|
|
clearTimeout(reconTout); |
|
|
|
|
clearTimeout(heartbeatTout); |
|
|
|
|
|
|
|
|
|
ws = new WebSocket("ws://" + _root + "/term/update.ws"); |
|
|
|
|
ws.onopen = onOpen; |
|
|
|
|
ws.onclose = onClose; |
|
|
|
|
ws.onmessage = onMessage; |
|
|
|
|
|
|
|
|
|
console.log("Opening socket."); |
|
|
|
|
|
|
|
|
|
// Ask for initial data
|
|
|
|
|
$.get('http://'+_root+'/term/init', function(resp, status) { |
|
|
|
|
if (status !== 200) location.reload(true); |
|
|
|
|
console.log("Data received!"); |
|
|
|
|
Screen.load(resp); |
|
|
|
|
heartbeat(); |
|
|
|
|
|
|
|
|
|
showPage(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function heartbeat() { |
|
|
|
@ -1729,7 +1732,7 @@ var Conn = (function() { |
|
|
|
|
}, { |
|
|
|
|
timeout: 100, |
|
|
|
|
}); |
|
|
|
|
}, 500); |
|
|
|
|
}, 1000); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|