|
@ -128,12 +128,12 @@ console.log("reading from db...."); |
|
|
// Lefos-- variable poy krata to trexon room tou xrhsth kathe fora
|
|
|
// Lefos-- variable poy krata to trexon room tou xrhsth kathe fora
|
|
|
var curRoom; |
|
|
var curRoom; |
|
|
|
|
|
|
|
|
var url = "mongodb://mongo:27017/"; |
|
|
// var url = "mongodb://mongo:27017/";
|
|
|
MongoClient.connect(url, function (err, db) { |
|
|
// MongoClient.connect(url, function (err, db) {
|
|
|
if (err) throw err; |
|
|
// if (err) throw err;
|
|
|
var dbo = db.db("fluentdb"); |
|
|
// var dbo = db.db("fluentdb");
|
|
|
dbo.collection("test", onCollectionNew); |
|
|
// dbo.collection("test", onCollectionNew);
|
|
|
}); |
|
|
// });
|
|
|
|
|
|
|
|
|
function onCollectionNew(err, collection) { |
|
|
function onCollectionNew(err, collection) { |
|
|
let options = { |
|
|
let options = { |
|
@ -144,20 +144,13 @@ function onCollectionNew(err, collection) { |
|
|
}; |
|
|
}; |
|
|
var cursor = collection.find({}, options).stream(); |
|
|
var cursor = collection.find({}, options).stream(); |
|
|
var itemsProcessed = 0; |
|
|
var itemsProcessed = 0; |
|
|
|
|
|
var room = this; |
|
|
|
|
|
console.log("Inside callback: " + room); |
|
|
cursor.on("data", function (data) { |
|
|
cursor.on("data", function (data) { |
|
|
var obj = JSON.parse(JSON.stringify(data)); |
|
|
var obj = JSON.parse(JSON.stringify(data)); |
|
|
// obj.log = JSON.parse(obj.log);
|
|
|
|
|
|
// var jsonfinal = [];
|
|
|
|
|
|
|
|
|
|
|
|
// obj.forEach((value) => {
|
|
|
|
|
|
// if (value.log.includes("app_name")) {
|
|
|
|
|
|
// jsonfinal.push(JSON.parse(value.log));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
// Pernaw karfota to room pros to paron
|
|
|
// Pernaw karfota to room pros to paron
|
|
|
io.in(curRoom).emit("logsend", obj); |
|
|
io.in(room).emit("logsend", obj); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -206,6 +199,26 @@ io.on("connection", (s) => { |
|
|
})(); |
|
|
})(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
s.on("onevent", function (data) { |
|
|
|
|
|
console.log("I GOT THE DATA: ", data); |
|
|
|
|
|
var user = data; |
|
|
|
|
|
|
|
|
|
|
|
console.log("reading from db...."); |
|
|
|
|
|
|
|
|
|
|
|
// var url = "mongodb://mongo:27017/";
|
|
|
|
|
|
// MongoClient.connect(url, function (err, db) {
|
|
|
|
|
|
// if (err) throw err;
|
|
|
|
|
|
// var dbo = db.db("fluentdb");
|
|
|
|
|
|
// dbo.collection("test", onCollectionNew);
|
|
|
|
|
|
// });
|
|
|
|
|
|
var url = "mongodb://mongo:27017/"; |
|
|
|
|
|
MongoClient.connect(url, function (err, db) { |
|
|
|
|
|
if (err) throw err; |
|
|
|
|
|
var dbo = db.db("fluentdb"); |
|
|
|
|
|
dbo.collection("test", onCollectionNew.bind(user)); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
setTimeout(function () { |
|
|
setTimeout(function () { |
|
|
if (!s.auth) { |
|
|
if (!s.auth) { |
|
|
console.log("Disconnecting timeout socket ", s.id); |
|
|
console.log("Disconnecting timeout socket ", s.id); |
|
@ -216,7 +229,6 @@ io.on("connection", (s) => { |
|
|
s.join(room); |
|
|
s.join(room); |
|
|
console.log("joining rooom", s.rooms); |
|
|
console.log("joining rooom", s.rooms); |
|
|
console.log(room + " created "); |
|
|
console.log(room + " created "); |
|
|
//LEFOS == Krataw to room gia na douleuei on event dunamika se kathe xrhsth
|
|
|
|
|
|
curRoom = room; |
|
|
curRoom = room; |
|
|
// });
|
|
|
// });
|
|
|
} |
|
|
} |
|
|