# HG changeset patch # User John "Elwin" Edwards # Date 1336606571 25200 # Node ID d051aad3e95fc67e424c3decc11025b91622d8a9 # Parent 826a7ced69f894a4585000fb2cf2ae333a01bbea webtty: begin experimenting with JSON protocol. diff -r 826a7ced69f8 -r d051aad3e95f shterm.js --- a/shterm.js Wed May 09 13:38:05 2012 -0700 +++ b/shterm.js Wed May 09 16:36:11 2012 -0700 @@ -302,13 +302,13 @@ 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 -r 826a7ced69f8 -r d051aad3e95f webtty.js --- a/webtty.js Wed May 09 13:38:05 2012 -0700 +++ b/webtty.js Wed May 09 16:36:11 2012 -0700 @@ -182,7 +182,8 @@ 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;