From 78ee46aa49533bbda8fc86220447199de6ed3794 Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Mon, 12 Mar 2012 08:21:34 +0100 Subject: [PATCH] Username is shown again in the frontend --- assets/html/main.html | 2 +- assets/js/serverval.js | 2 +- assets/js/session.js | 11 +++++++++-- src/http/response/session.c | 5 +++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/assets/html/main.html b/assets/html/main.html index b9d14d5..2fb4daa 100644 --- a/assets/html/main.html +++ b/assets/html/main.html @@ -65,7 +65,7 @@

Testpage

- Welcome You!!!
+ Welcome!!!

diff --git a/assets/js/serverval.js b/assets/js/serverval.js index 21f7d08..bdb848b 100644 --- a/assets/js/serverval.js +++ b/assets/js/serverval.js @@ -17,6 +17,7 @@ ServerVal.prototype.loadJSON = function(data) this.vnext = data.vnext; this.value = data.value; + $.getJSON("/sessinfo/", $.proxy(sess.loadJSON, sess)); this.show(); } @@ -57,7 +58,6 @@ ServerVal.prototype.process = function() break; } }, this)); - $.getJSON("/sessinfo/", $.proxy(sess.loadJSON, sess)); } else { diff --git a/assets/js/session.js b/assets/js/session.js index 869f871..2445b1a 100644 --- a/assets/js/session.js +++ b/assets/js/session.js @@ -7,6 +7,7 @@ function Session(sId) this.id = "none" this.timeout = 0; this.timeleft = 0; + this.username = ""; this.interval = null; this.draw(); @@ -17,6 +18,10 @@ Session.prototype.loadJSON = function(data) this.id = ("0" == data.id)? "none" : data.id; this.timeout = data.timeout * 10; this.timeleft = data.timeleft * 10; + this.username = data.username; + + this.eSid.empty().append(this.id); + $("#main span:eq(0)").empty().append(" " + this.username); this.draw(); if (0 < this.timeleft) @@ -25,8 +30,6 @@ Session.prototype.loadJSON = function(data) Session.prototype.draw = function() { - this.eSid.empty().append(this.id); - this.context.fillStyle = "rgb(255, 0, 0)"; this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); @@ -62,6 +65,10 @@ Session.prototype.stop = function() this.id = "none"; this.timeout = 0; this.timeleft = 0; + this.username = ""; + + this.eSid.empty().append(this.id); + $("#main span:eq(0)").empty().append(" " + this.username); this.draw(); } diff --git a/src/http/response/session.c b/src/http/response/session.c index 2075a62..c1b15f8 100644 --- a/src/http/response/session.c +++ b/src/http/response/session.c @@ -36,7 +36,7 @@ #include "utils/memory.h" -#define RESP_DATA "{\"id\":\"%lu\",\"timeout\":%d,\"timeleft\":%ld}" +#define RESP_DATA "{\"id\":\"%lu\",\"timeout\":%d,\"timeleft\":%ld,\"username\":\"%s\"}" HttpResponse httpResponseSession(Session session) @@ -57,7 +57,8 @@ httpResponseSession(Session session) nbuf = sprintf(buffer, RESP_DATA, (NULL != session)? session->id : 0, (NULL != session)? SESSION_LIVETIME : 0, - (NULL != session)? session->livetime - time(NULL) : 0); + (NULL != session)? session->livetime - time(NULL) : 0, + (NULL != session)? session->username : ""); message->nbody = nbuf; message->body = malloc(nbuf);