Browse Source

Username is shown again in the frontend

master
Georg Hopp 14 years ago
parent
commit
78ee46aa49
  1. 2
      assets/html/main.html
  2. 2
      assets/js/serverval.js
  3. 11
      assets/js/session.js
  4. 5
      src/http/response/session.c

2
assets/html/main.html

@ -65,7 +65,7 @@
</div>
<div id="main">
<h1>Testpage</h1>
Welcome You!!!<br />
Welcome<span></span>!!!<br />
<img src="/image/me" />
</div>
<hr />

2
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 {

11
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();
}

5
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);

Loading…
Cancel
Save