|
@ -136,7 +136,7 @@ var curRoom; |
|
|
// dbo.collection("test", onCollectionNew);
|
|
|
// dbo.collection("test", onCollectionNew);
|
|
|
// });
|
|
|
// });
|
|
|
|
|
|
|
|
|
function onCollectionNew(err, collection) { |
|
|
async function onCollectionNew(err, collection) { |
|
|
/* |
|
|
/* |
|
|
Prepei na elegxw kathe fora an to socket id tou user einai energo |
|
|
Prepei na elegxw kathe fora an to socket id tou user einai energo |
|
|
wste na mhn diathreitai zwntanh h callback kai lamvanw dublicate |
|
|
wste na mhn diathreitai zwntanh h callback kai lamvanw dublicate |
|
@ -154,9 +154,14 @@ function onCollectionNew(err, collection) { |
|
|
var sid = this.id; |
|
|
var sid = this.id; |
|
|
console.log("Inside callback: " + room + " Id: " + sid); |
|
|
console.log("Inside callback: " + room + " Id: " + sid); |
|
|
// LEFOS --- STORE USER IN REDIS
|
|
|
// LEFOS --- STORE USER IN REDIS
|
|
|
var rep = setUser(room, room); |
|
|
var rep = setUser(sid, room); |
|
|
|
|
|
|
|
|
cursor.on("data", function (data) { |
|
|
cursor.on("data", async function (data) { |
|
|
|
|
|
cursor.pause(); |
|
|
|
|
|
var res = await getkey(sid); |
|
|
|
|
|
|
|
|
|
|
|
if (res == "1") { |
|
|
|
|
|
cursor.resume(); |
|
|
var obj = JSON.parse(JSON.stringify(data)); |
|
|
var obj = JSON.parse(JSON.stringify(data)); |
|
|
// var getres = getkey(sid);
|
|
|
// var getres = getkey(sid);
|
|
|
// if (getres == "1") {
|
|
|
// if (getres == "1") {
|
|
@ -166,6 +171,11 @@ function onCollectionNew(err, collection) { |
|
|
// cursor.close();
|
|
|
// cursor.close();
|
|
|
// }
|
|
|
// }
|
|
|
io.in(room).emit("logsend", obj); |
|
|
io.in(room).emit("logsend", obj); |
|
|
|
|
|
} else if (res == "2") { |
|
|
|
|
|
cursor.resume(); |
|
|
|
|
|
console.log("Cursor is closing..."); |
|
|
|
|
|
cursor.close(); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -218,7 +228,7 @@ io.on("connection", (s) => { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
s.on("onevent", function (data) { |
|
|
s.on("onevent", function (data) { |
|
|
console.log("I GOT THE DATA: ", data); |
|
|
//console.log("I GOT THE DATA: ", data);
|
|
|
var binddata = { |
|
|
var binddata = { |
|
|
user: data, |
|
|
user: data, |
|
|
id: s.id, |
|
|
id: s.id, |
|
@ -227,7 +237,9 @@ io.on("connection", (s) => { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
s.on("disconnect", function () { |
|
|
s.on("disconnect", function () { |
|
|
console.log("Socket: " + s.id + " Disconnected"); |
|
|
//console.log("Socket: " + s.id + " Disconnected");
|
|
|
|
|
|
console.log("Deleting " + s.id + "From redis"); |
|
|
|
|
|
pubClient.del(s.id); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
setTimeout(function () { |
|
|
setTimeout(function () { |
|
@ -505,7 +517,7 @@ function onlogfile(path) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async function checkstream(data) { |
|
|
async function checkstream(data) { |
|
|
var res = await getkey(data.user); |
|
|
var res = await getkey(data.id); |
|
|
if (res == "1") { |
|
|
if (res == "1") { |
|
|
console.log("Stream is on!"); |
|
|
console.log("Stream is on!"); |
|
|
} else { |
|
|
} else { |
|
@ -911,7 +923,7 @@ async function getkey(id) { |
|
|
resolve(null); |
|
|
resolve(null); |
|
|
} else { |
|
|
} else { |
|
|
if (reply) { |
|
|
if (reply) { |
|
|
console.log("---------fount----------"); |
|
|
//console.log("---------fount----------");
|
|
|
resolve(1); |
|
|
resolve(1); |
|
|
} else { |
|
|
} else { |
|
|
console.log("----------not fount------------"); |
|
|
console.log("----------not fount------------"); |
|
|