Permalink
Browse files

V0.3

  • Loading branch information...
mrohad committed Aug 19, 2010
1 parent 1b5dff5 commit d88a1a2feec89348cd0adb90ac723a7c63290c88
Showing with 27 additions and 18 deletions.
  1. +2 −1 lib/jssp.js
  2. +24 −16 lib/session.js
  3. +1 −1 settings.json
View
@@ -110,8 +110,9 @@ function handleRequest(req,res,cleanPathname,newSessionId){
var sessionId = utils.getSessionId(cookie);
if(newSessionId!=undefined)//forward
sessionId = newSessionId;
- else
+ else{
sessionScope.hello(sessionId);
+ }
if(!path.endsWith("."+globalSettings.server_script.ext)){
sendHeaders(req, res,undefined, stats.size, mime.mimeType(path), stats.mtime);
var readStream = fs.createReadStream(path);
View
@@ -19,27 +19,32 @@ function sessionScope(sessionTimeOutMinutes,webAppName){
this.numberOfMin = (sessionTimeOutMinutes==undefined?30:sessionTimeOutMinutes);//default 30 min
this.numberOfMili = this.numberOfMin*60*1000;
log.info("Session has been created, session timeout = "+this.numberOfMin+" minutes");
-
+ this.latestApllication = undefined;
+
this.hello = function(uid){
- if(uid != undefined && this.timers[this.webAppName+uid] != undefined){
- clearTimeout(this.timers[this.webAppName+uid]);
- this.timers[this.webAppName+uid] = this.setSessionTimeout(uid);
+ log.debug("sessionManger.hello: uid - " + uid);
+ if(uid != undefined ){
+ if(this.timers[this.webAppName+uid] != undefined)
+ clearTimeout(this.timers[this.webAppName+uid]);
+ this.timers[this.webAppName+uid] = this.setSessionTimeout(this.latestApllication,uid);
}
};
this.setSessionTimeout = function(application,uid){//adding *minutes* to the uid timeout
- return setTimeout((function(application,sid){
- if(sid!=undefined){
- this.remove(application,sid);
- this.timers[this.webAppName+sid] = undefined;
- log.info("Clearing session: "+this.webAppName+sid);
+ log.debug("session.setSessionTimeout: uid - " + uid + " app - " + application);
+ var sessionObj = this;
+ return setTimeout((function(application,uid){
+ if(uid!=undefined && application!=undefined){
+ sessionObj.remove(application,uid);
+ sessionObj.timers[sessionObj.webAppName+uid] = undefined;
+ log.info("Clearing session: "+sessionObj.webAppName+uid);
}
})
,this.numberOfMili,application,uid);
};
- this.remove = function(application,nuid,cb){
- application.remove(seprator,uid,cb);
+ this.remove = function(application,uid,cb){
+ application.remove(uid,cb);
};
this.saveObjectInSession =function(application,key,value,uid,obj,cb){
@@ -49,16 +54,18 @@ function sessionScope(sessionTimeOutMinutes,webAppName){
this.set = function(application,key,value,uid,cb){
log.debug("sessionMap.set: key-"+key+" value-" +value+" uid-"+uid);
+ this.latestApllication = application;
var cont = true;
if(uid==undefined){
uid = createUUID();
- //application.get(seprator,uid,function(result){
+ var sessionObj = this;
+ //application.get(uid,function(result){
//if(result!=undefined)
- // this.set(key, value, undefined, cb);
+ // this.set(application,key, value, undefined, cb);
//else{
log.debug("New session UID:"+uid);
- this.setSessionTimeout(application,uid);
- this.saveObjectInSession(application,key,value,uid,new Object(),cb);
+ sessionObj.setSessionTimeout(application,uid);
+ sessionObj.saveObjectInSession(application,key,value,uid,new Object(),cb);
//}
//});
}else{
@@ -70,13 +77,14 @@ function sessionScope(sessionTimeOutMinutes,webAppName){
saveFunc(application,key,value,uid,new Object(),cb);
});
}
- log.debug("sessionMap.set: return uid-"+uid);
+ //log.debug("sessionMap.set: return uid-"+uid);
return uid;
};
this.get = function(application,key,uid,cb){
log.debug("sessionMap.get: key-"+key+" uid-"+uid);
+ this.latestApllication = application;
if(uid==undefined)
cb(undefined);
else{
View
@@ -12,7 +12,7 @@
"end":"?>",
"session_minutes":1,
"memcached":{
- "enable":1,
+ "enable":0,
"server":"localhost",
"port":11211
}

0 comments on commit d88a1a2

Please sign in to comment.