Commit 78ee46aa49533bbda8fc86220447199de6ed3794
1 parent
27457db4
Username is shown again in the frontend
Showing
4 changed files
with
14 additions
and
6 deletions
@@ -17,6 +17,7 @@ ServerVal.prototype.loadJSON = function(data) | @@ -17,6 +17,7 @@ ServerVal.prototype.loadJSON = function(data) | ||
17 | this.vnext = data.vnext; | 17 | this.vnext = data.vnext; |
18 | this.value = data.value; | 18 | this.value = data.value; |
19 | 19 | ||
20 | + $.getJSON("/sessinfo/", $.proxy(sess.loadJSON, sess)); | ||
20 | this.show(); | 21 | this.show(); |
21 | } | 22 | } |
22 | 23 | ||
@@ -57,7 +58,6 @@ ServerVal.prototype.process = function() | @@ -57,7 +58,6 @@ ServerVal.prototype.process = function() | ||
57 | break; | 58 | break; |
58 | } | 59 | } |
59 | }, this)); | 60 | }, this)); |
60 | - $.getJSON("/sessinfo/", $.proxy(sess.loadJSON, sess)); | ||
61 | } | 61 | } |
62 | 62 | ||
63 | else { | 63 | else { |
@@ -7,6 +7,7 @@ function Session(sId) | @@ -7,6 +7,7 @@ function Session(sId) | ||
7 | this.id = "none" | 7 | this.id = "none" |
8 | this.timeout = 0; | 8 | this.timeout = 0; |
9 | this.timeleft = 0; | 9 | this.timeleft = 0; |
10 | + this.username = ""; | ||
10 | this.interval = null; | 11 | this.interval = null; |
11 | 12 | ||
12 | this.draw(); | 13 | this.draw(); |
@@ -17,6 +18,10 @@ Session.prototype.loadJSON = function(data) | @@ -17,6 +18,10 @@ Session.prototype.loadJSON = function(data) | ||
17 | this.id = ("0" == data.id)? "none" : data.id; | 18 | this.id = ("0" == data.id)? "none" : data.id; |
18 | this.timeout = data.timeout * 10; | 19 | this.timeout = data.timeout * 10; |
19 | this.timeleft = data.timeleft * 10; | 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 | this.draw(); | 26 | this.draw(); |
22 | if (0 < this.timeleft) | 27 | if (0 < this.timeleft) |
@@ -25,8 +30,6 @@ Session.prototype.loadJSON = function(data) | @@ -25,8 +30,6 @@ Session.prototype.loadJSON = function(data) | ||
25 | 30 | ||
26 | Session.prototype.draw = function() | 31 | Session.prototype.draw = function() |
27 | { | 32 | { |
28 | - this.eSid.empty().append(this.id); | ||
29 | - | ||
30 | this.context.fillStyle = "rgb(255, 0, 0)"; | 33 | this.context.fillStyle = "rgb(255, 0, 0)"; |
31 | this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); | 34 | this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); |
32 | 35 | ||
@@ -62,6 +65,10 @@ Session.prototype.stop = function() | @@ -62,6 +65,10 @@ Session.prototype.stop = function() | ||
62 | this.id = "none"; | 65 | this.id = "none"; |
63 | this.timeout = 0; | 66 | this.timeout = 0; |
64 | this.timeleft = 0; | 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 | this.draw(); | 73 | this.draw(); |
67 | } | 74 | } |
@@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
36 | 36 | ||
37 | #include "utils/memory.h" | 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 | HttpResponse | 41 | HttpResponse |
42 | httpResponseSession(Session session) | 42 | httpResponseSession(Session session) |
@@ -57,7 +57,8 @@ httpResponseSession(Session session) | @@ -57,7 +57,8 @@ httpResponseSession(Session session) | ||
57 | nbuf = sprintf(buffer, RESP_DATA, | 57 | nbuf = sprintf(buffer, RESP_DATA, |
58 | (NULL != session)? session->id : 0, | 58 | (NULL != session)? session->id : 0, |
59 | (NULL != session)? SESSION_LIVETIME : 0, | 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 | message->nbody = nbuf; | 63 | message->nbody = nbuf; |
63 | message->body = malloc(nbuf); | 64 | message->body = malloc(nbuf); |
Please
register
or
login
to post a comment