Skip to content
Snippets Groups Projects
Commit ff204684 authored by wactbprot's avatar wactbprot
Browse files

safe lib/exchangeUpdateTime.js

parent 66655a44
No related branches found
No related tags found
No related merge requests found
......@@ -37,16 +37,26 @@ var ini = function (cb){
exports.ini = ini;
mem.on('message',function (ch, path){
var mpid = path[0];
mem.get([mpid, "exchange","start_time"], function(err, res){
var ct =((new Date()).getTime() - res.Value)/60000
, val = {Value: Math.round(ct*1000)/1000,
Unit:"min"};
mem.set([mpid, "exchange","update_time"], val, function (err){
var mpid = path[0];
mem.get([mpid, "exchange","start_time"], function(err, res){
if(!err){
log.trace(ok
, "exchange access, time updated");
}
});
});
if(res && res.Value) {
var ct =((new Date()).getTime() - res.Value)/60000
, val = {Value: Math.round(ct*1000)/1000,
Unit:"min"};
mem.set([mpid, "exchange","update_time"], val, function (err){
if(!err){
log.trace(ok
, "exchange access, time updated");
}
});
} else {
log.error(err);
}
} else {
err = new Error("result undefined");
log.error(err,
"returned value is: " + res);
}
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment