Move credentials into the drivers.
The session id, or whether the session is currently active on the server, are better handled in the drivers than in termemu.js.
This commit is contained in:
parent
ceed48eee5
commit
553f07360c
3 changed files with 29 additions and 28 deletions
15
shterm.js
15
shterm.js
|
|
@ -2,6 +2,7 @@
|
|||
* is running a shell via the webtty.js server.
|
||||
*/
|
||||
|
||||
var isalive = false; // Whether the session is currently active.
|
||||
var nsend = 0; // The number of the next packet to send.
|
||||
var nrecv = 0; // The next packet expected.
|
||||
var msgQ = []; // Queue for out-of-order messages.
|
||||
|
|
@ -147,7 +148,7 @@ function processMsg(response) {
|
|||
}
|
||||
|
||||
function getData() {
|
||||
if (!termemu.alive)
|
||||
if (!isalive)
|
||||
return;
|
||||
var datareq = new XMLHttpRequest();
|
||||
datareq.onreadystatechange = function () {
|
||||
|
|
@ -157,7 +158,7 @@ function getData() {
|
|||
return;
|
||||
else if (response.t == "E") {
|
||||
if (response.c == 1) {
|
||||
termemu.alive = false;
|
||||
isalive = false;
|
||||
debug(1, "Server error: " + response.s);
|
||||
}
|
||||
}
|
||||
|
|
@ -182,7 +183,7 @@ function postResponseHandler() {
|
|||
return;
|
||||
else if (response.t == "E") {
|
||||
if (response.c == 1) {
|
||||
termemu.alive = false;
|
||||
isalive = false;
|
||||
debug(1, "Server error: " + response.s);
|
||||
}
|
||||
return;
|
||||
|
|
@ -245,7 +246,7 @@ function sendkey(ev) {
|
|||
debug(1, "Ignoring keycode " + keynum);
|
||||
return;
|
||||
}
|
||||
if (termemu.alive)
|
||||
if (isalive)
|
||||
ev.preventDefault();
|
||||
var formdata = {"t": "d", "n": nsend++, "d": code};
|
||||
var datareq = new XMLHttpRequest();
|
||||
|
|
@ -333,7 +334,7 @@ function togglectrl() {
|
|||
}
|
||||
|
||||
function login(h, w) {
|
||||
if (termemu.alive)
|
||||
if (isalive)
|
||||
return;
|
||||
params = {"login": true, "h": h, "w": w};
|
||||
var req = new XMLHttpRequest();
|
||||
|
|
@ -343,7 +344,7 @@ function login(h, w) {
|
|||
if (logindict.login) {
|
||||
/* Success */
|
||||
termemu.resize(logindict.h, logindict.w);
|
||||
termemu.alive = true;
|
||||
isalive = true;
|
||||
nsend = 0;
|
||||
nrecv = 0;
|
||||
setTitle("Logged in");
|
||||
|
|
@ -366,7 +367,7 @@ function stop() {
|
|||
if (req.readyState == 4 && req.status == 200) {
|
||||
/* Figure out whether or not it worked. */
|
||||
/* FIXME the server might respond with output. */
|
||||
termemu.alive = false;
|
||||
isalive = false;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue