diff --git a/shterm.js b/shterm.js index 817b9a9..f15295a 100644 --- a/shterm.js +++ b/shterm.js @@ -302,13 +302,13 @@ function login(h, w) { req.onreadystatechange = function () { if (req.readyState == 4 && req.status == 200) { var datalines = req.responseText.split("\n"); - if (datalines[0] == 'l1') { + var logindict = JSON.parse(req.responseText); + if (logindict.login) { /* Success */ - // FIXME extract the size from the response instead of hardcoding - termemu.resize(25, 80); + termemu.resize(logindict.h, logindict.w); termemu.alive = true; setTitle("Logged in"); - debug(1, "Logged in with id " + datalines[1]); + debug(1, "Logged in with id " + logindict.id); getData(); return; } diff --git a/webtty.js b/webtty.js index 7172746..4e5e128 100755 --- a/webtty.js +++ b/webtty.js @@ -182,7 +182,8 @@ function login(req, res, formdata) { var nsession = new TermSession(sessid, h, w); resheaders["Set-Cookie"] = "ID=" + sessid; res.writeHead(200, resheaders); - res.write("l1\n" + sessid + "\n" + String(h) + "x" + String(w) + "\n"); + var logindict = {"login": true, "id": sessid, "w": w, "h": h}; + res.write(JSON.stringify(logindict)); res.end(); console.log("Started new session with key " + sessid + ", pid " + nsession.child.pid); return;