Browse Source

sync redis

master
zeus 4 years ago
parent
commit
967dc94ccf
  1. 18
      swarmlab-app/src/run/app.js

18
swarmlab-app/src/run/app.js

@ -414,6 +414,9 @@ cors(corsOptions), (req, res, next) => {
// socket
// ***************************************************
function getSHA256ofJSON(input){
return crypto.createHash('sha256').update(JSON.stringify(input)).digest('hex')
}
function onCollection(err, collection) {
@ -428,6 +431,7 @@ function onCollection(err, collection) {
var reslog = new Object();
var now = new Date();
cursor.on('data', function (data) {
var issend = getSHA256ofJSON(data)
//io.in('anagnostopoulos@uniwa.gr').emit("logdata", data);
console.log('++++++++' + JSON.stringify(data));
@ -469,8 +473,14 @@ function onCollection(err, collection) {
var user = resob1.res25creator
console.log('datauser ' + JSON.stringify(user));
console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>> '+JSON.stringify(reslog));
pubClient.get(issend, function(err, object) {
if(err == null){
pubClient.set(issend, itemsProcessed, function(err, res) {
io.in(user).emit("logdata", reslog);
});
}
itemsProcessed++;
});
})()
}else{
@ -495,8 +505,16 @@ function onCollection(err, collection) {
//console.log("RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRr", JSON.stringify(io.sockets.adapter.rooms)); // Set { <socket.id> }
pubClient.get(issend, function(err, object) {
if(err == null){
pubClient.set(issend, itemsProcessed, function(err, res) {
io.in(user).emit("logdata", reslog);
});
}
itemsProcessed++;
});
//io.in(user).emit("logdata", reslog);
//itemsProcessed++;
});
}
});

Loading…
Cancel
Save