Commit 78ee46aa49533bbda8fc86220447199de6ed3794

Authored by Georg Hopp
1 parent 27457db4

Username is shown again in the frontend

... ... @@ -65,7 +65,7 @@
65 65 </div>
66 66 <div id="main">
67 67 <h1>Testpage</h1>
68   - Welcome You!!!<br />
  68 + Welcome<span></span>!!!<br />
69 69 <img src="/image/me" />
70 70 </div>
71 71 <hr />
... ...
... ... @@ -17,6 +17,7 @@ ServerVal.prototype.loadJSON = function(data)
17 17 this.vnext = data.vnext;
18 18 this.value = data.value;
19 19
  20 + $.getJSON("/sessinfo/", $.proxy(sess.loadJSON, sess));
20 21 this.show();
21 22 }
22 23
... ... @@ -57,7 +58,6 @@ ServerVal.prototype.process = function()
57 58 break;
58 59 }
59 60 }, this));
60   - $.getJSON("/sessinfo/", $.proxy(sess.loadJSON, sess));
61 61 }
62 62
63 63 else {
... ...
... ... @@ -7,6 +7,7 @@ function Session(sId)
7 7 this.id = "none"
8 8 this.timeout = 0;
9 9 this.timeleft = 0;
  10 + this.username = "";
10 11 this.interval = null;
11 12
12 13 this.draw();
... ... @@ -17,6 +18,10 @@ Session.prototype.loadJSON = function(data)
17 18 this.id = ("0" == data.id)? "none" : data.id;
18 19 this.timeout = data.timeout * 10;
19 20 this.timeleft = data.timeleft * 10;
  21 + this.username = data.username;
  22 +
  23 + this.eSid.empty().append(this.id);
  24 + $("#main span:eq(0)").empty().append(" " + this.username);
20 25
21 26 this.draw();
22 27 if (0 < this.timeleft)
... ... @@ -25,8 +30,6 @@ Session.prototype.loadJSON = function(data)
25 30
26 31 Session.prototype.draw = function()
27 32 {
28   - this.eSid.empty().append(this.id);
29   -
30 33 this.context.fillStyle = "rgb(255, 0, 0)";
31 34 this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
32 35
... ... @@ -62,6 +65,10 @@ Session.prototype.stop = function()
62 65 this.id = "none";
63 66 this.timeout = 0;
64 67 this.timeleft = 0;
  68 + this.username = "";
  69 +
  70 + this.eSid.empty().append(this.id);
  71 + $("#main span:eq(0)").empty().append(" " + this.username);
65 72
66 73 this.draw();
67 74 }
... ...
... ... @@ -36,7 +36,7 @@
36 36
37 37 #include "utils/memory.h"
38 38
39   -#define RESP_DATA "{\"id\":\"%lu\",\"timeout\":%d,\"timeleft\":%ld}"
  39 +#define RESP_DATA "{\"id\":\"%lu\",\"timeout\":%d,\"timeleft\":%ld,\"username\":\"%s\"}"
40 40
41 41 HttpResponse
42 42 httpResponseSession(Session session)
... ... @@ -57,7 +57,8 @@ httpResponseSession(Session session)
57 57 nbuf = sprintf(buffer, RESP_DATA,
58 58 (NULL != session)? session->id : 0,
59 59 (NULL != session)? SESSION_LIVETIME : 0,
60   - (NULL != session)? session->livetime - time(NULL) : 0);
  60 + (NULL != session)? session->livetime - time(NULL) : 0,
  61 + (NULL != session)? session->username : "");
61 62
62 63 message->nbody = nbuf;
63 64 message->body = malloc(nbuf);
... ...
Please register or login to post a comment