Initializes a new SessionVocStore . You can define an options array to specifiy
the host and port.
param: Object options api: public
|
function SessionVocStore (options) {
var host = options && options.host;
var port = options && options.port;
var self = this;
self.description = 'Secure and reliable session store using a SessionVOC';
self.client = sessionvocClient.createClient(host, port);
self.datainfo = null;
self.client.on('ready', function(dinfo) {
self.datainfo = dinfo;
});
};
|
Creates a new session object.
|
SessionVocStore.prototype.createSession = function (sid, data, next) {
next(new Session(this, sid, data));
};
|
Reads or creates a new Session object. If the session could be read, then
the function 'read' is called. If the session could not be restored, but a
new session could be created then the function 'created' is called. In case
of an error, the 'error' function is called. If 'sid' is not given, then
a new session (and sid) is created.
param: String sid (optional) param: Function created(session) param: Function read(session) param: Function error(err) api: public
|
SessionVocStore.prototype.loadSession = function (sid, created, loaded, error) {
var self = this;
if (typeof sid === 'function') {
error = loaded;
loaded = created;
created = sid;
sid = false;
}
if (sid) {
self.readSessionVoc(sid,
function (result) {
self.createSession(sid, result, loaded);
},
function () {
self.createSessionVoc(function (sid, result) {
self.createSession(sid, result, created);
},
error);
},
error);
}
else {
self.createSessionVoc(function (sid, result) {
self.createSession(sid, result, created);
},
error);
}
};
|