From 8bc5d1821ed4382d14f9e16f6aa0df2e284cd87d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Mon, 4 Jun 2018 22:27:02 +0200 Subject: [PATCH 01/24] Updates --- server/handlers/io.js | 3 +++ server/public/assets/js/listeners.js | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/server/handlers/io.js b/server/handlers/io.js index 7b53fba4..c7b1bc2b 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -79,6 +79,7 @@ module.exports = function() { }); socket.on('chromecast', function(msg) { + console.log("chromecast event", msg); try { if(typeof(msg) == "object" && msg.hasOwnProperty("guid") && msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel") && typeof(msg.guid) == "string" && @@ -99,6 +100,7 @@ module.exports = function() { coll = coll.substring(0, coll.indexOf("?")); } in_list = true; + console.log("chromecast list", coll); chromecast_object = true; socket.join(coll); } @@ -110,6 +112,7 @@ module.exports = function() { }); socket.on("get_id", function() { + console.log("gotten request from mobile", Functions.getSession(socket)); socket.emit("id_chromecast", Functions.getSession(socket)); }); diff --git a/server/public/assets/js/listeners.js b/server/public/assets/js/listeners.js index a5426203..da00e801 100755 --- a/server/public/assets/js/listeners.js +++ b/server/public/assets/js/listeners.js @@ -296,7 +296,7 @@ initializeCastApi = function() { castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", start: Player.np.start, end: Player.np.end, videoId: video_id, seekTo: _seekTo, channel: chan.toLowerCase(), source: videoSource, thumbnail: Player.np.thumbnail}) castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail}) - if(Helper.mobilecheck() && !chromecast_specs_sent) { + if(Helper.mobilecheck()) { socket.emit("get_id"); } hide_native(1); @@ -322,6 +322,9 @@ initializeCastApi = function() { } catch(event){ _seekTo = seekTo; } + if(Helper.mobilecheck()) { + socket.emit("get_id"); + } castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", start: Player.np.start, end: Player.np.end, videoId: video_id, seekTo: _seekTo, channel: chan.toLowerCase(), source: videoSource, thumbnail: Player.np.thumbnail}) castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail}) hide_native(1); From 3720cea40fff4bd6ceaf4acc178930028e6e8ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Mon, 4 Jun 2018 22:30:36 +0200 Subject: [PATCH 02/24] Sending channel on mobilespecs now --- server/public/assets/js/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/public/assets/js/functions.js b/server/public/assets/js/functions.js index 6d5240a3..91677306 100644 --- a/server/public/assets/js/functions.js +++ b/server/public/assets/js/functions.js @@ -450,7 +450,7 @@ function get_list_listener(){ }); socket.on("id_chromecast", function(msg) { chromecast_specs_sent = true; - castSession.sendMessage("urn:x-cast:zoff.me", {type: "mobilespecs", guid: msg, socketid: socket.id}) + castSession.sendMessage("urn:x-cast:zoff.me", {type: "mobilespecs", guid: msg, socketid: socket.id, channel: chan.toLowerCase()}) }) } From ed55f0768a5a06cabd54b77172045ef2c85bb067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Mon, 4 Jun 2018 22:37:19 +0200 Subject: [PATCH 03/24] Trying some more debugs --- server/handlers/io.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/handlers/io.js b/server/handlers/io.js index c7b1bc2b..0fd3690d 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -83,7 +83,7 @@ module.exports = function() { try { if(typeof(msg) == "object" && msg.hasOwnProperty("guid") && msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel") && typeof(msg.guid) == "string" && - typeof(msg.channel) == "string" && typeof(msg.socket_id) == "string") { + typeof(msg.channel) == "string" && typeof(msg.socket_id) == "string" && msg.channel != "") { db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) { if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) { socket.cookie_id = msg.guid; @@ -398,6 +398,7 @@ module.exports = function() { socket.on('end', function(obj) { + console.log("end event", obj); if(obj.hasOwnProperty("channel") && obj.channel.indexOf("?") > -1){ var _list = obj.channel.substring(0, obj.channel.indexOf("?")); obj.channel = _list; From 2ebb35f377638b6101e79c8faed508d76453748b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Mon, 4 Jun 2018 22:45:28 +0200 Subject: [PATCH 04/24] Testing small things --- server/handlers/io.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/handlers/io.js b/server/handlers/io.js index 0fd3690d..bce99aeb 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -80,6 +80,8 @@ module.exports = function() { socket.on('chromecast', function(msg) { console.log("chromecast event", msg); + console.log(Functions.getSession(socket)); + console.log("cookie_id", socket.cookie_id); try { if(typeof(msg) == "object" && msg.hasOwnProperty("guid") && msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel") && typeof(msg.guid) == "string" && @@ -107,6 +109,7 @@ module.exports = function() { }); } } catch(e) { + console.log(e); return; } }); From d5c8aa3dae342b06ffe66c3961a4c18dc0b8195e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Mon, 4 Jun 2018 23:06:42 +0200 Subject: [PATCH 05/24] Printing tests to see what stop chromecast from joining channel --- server/handlers/io.js | 1 + server/routing/client/router.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/server/handlers/io.js b/server/handlers/io.js index bce99aeb..0188751a 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -87,6 +87,7 @@ module.exports = function() { msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel") && typeof(msg.guid) == "string" && typeof(msg.channel) == "string" && typeof(msg.socket_id) == "string" && msg.channel != "") { db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) { + console.log("test: ", connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel.length > 0, connected_users_channel[0].users.indexOf(msg.guid) > -1) if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) { socket.cookie_id = msg.guid; guid = msg.guid; diff --git a/server/routing/client/router.js b/server/routing/client/router.js index 81bd6529..76fbc1a2 100644 --- a/server/routing/client/router.js +++ b/server/routing/client/router.js @@ -34,10 +34,12 @@ try { } router.use(recaptcha.middleware.render, function(req, res, next) { + console.log("middleware render"); next(); // make sure we go to the next routes and don't stop here }); router.route('/:channel_name').get(function(req, res, next){ + console.log("channel_name get"); channel(req, res, next); }); @@ -47,10 +49,12 @@ router.route('/r/:base64data').get(function(req, res, next){ }); router.route('/').get(function(req, res, next){ + console.log("/ get"); root(req, res, next); }); router.route('/').post(function(req, res, next){ + console.log("/ post"); root(req, res, next); }); From c38ec389aca2989184d4506354a8f4161382dfa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Mon, 4 Jun 2018 23:09:29 +0200 Subject: [PATCH 06/24] Printing out existing users --- server/handlers/io.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/handlers/io.js b/server/handlers/io.js index 0188751a..809dcdfc 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -87,7 +87,7 @@ module.exports = function() { msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel") && typeof(msg.guid) == "string" && typeof(msg.channel) == "string" && typeof(msg.socket_id) == "string" && msg.channel != "") { db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) { - console.log("test: ", connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel.length > 0, connected_users_channel[0].users.indexOf(msg.guid) > -1) + console.log("test: ", connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel.length > 0, connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel) if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) { socket.cookie_id = msg.guid; guid = msg.guid; From b6c2a144455b8fb226e2213d6ca56a3449bc39c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Mon, 4 Jun 2018 23:13:13 +0200 Subject: [PATCH 07/24] trying with sending another id --- server/handlers/io.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/handlers/io.js b/server/handlers/io.js index 809dcdfc..d10d9498 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -117,7 +117,7 @@ module.exports = function() { socket.on("get_id", function() { console.log("gotten request from mobile", Functions.getSession(socket)); - socket.emit("id_chromecast", Functions.getSession(socket)); + socket.emit("id_chromecast", guid); }); socket.on("error_video", function(msg) { From 3bc0aa885f968df9af2b2e3ab6605fab1694401b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Mon, 4 Jun 2018 23:45:25 +0200 Subject: [PATCH 08/24] Trying way of emulating cookies for chromecast --- server/handlers/functions.js | 28 +++++++++++++++++++++++++--- server/handlers/io.js | 4 ++++ server/routing/client/router.js | 4 ---- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/server/handlers/functions.js b/server/handlers/functions.js index 75da87e5..8e26009d 100644 --- a/server/handlers/functions.js +++ b/server/handlers/functions.js @@ -252,6 +252,22 @@ function getSessionChatPass(id, callback) { } } + +function setChromecastHost(id, other_id, callback) { + try { + if(id == "empty" || id == undefined) { + callback(); + return; + } + connected_db.collection(id).update({_id: list}, {"chromecast": true, id: id}, {upsert: true}, function(e, docs) { + callback(true); + return; + }); + } catch(e) { + callback(false); + } +} + function setSessionUserPass(id, userpass, list, callback) { try { if(id == "empty" || id == undefined) { @@ -277,10 +293,16 @@ function getSessionAdminUser(id, list, callback) { var userpass = ""; var adminpass = ""; if(d.length > 0) { - if(d[0].userpass != undefined) userpass = d[0].userpass; - if(d[0].adminpass != undefined) adminpass = d[0].adminpass; + if(d.hasOwnProperty("chromecast") && d.chromecast) { + getSessionAdminUser(d.id, list, callback); + } else { + if(d[0].userpass != undefined) userpass = d[0].userpass; + if(d[0].adminpass != undefined) adminpass = d[0].adminpass; + callback(userpass, adminpass, true); + } + } else { + callback(userpass, adminpass, true); } - callback(userpass, adminpass, true); }) } catch(e) { callback("", "", false); diff --git a/server/handlers/io.js b/server/handlers/io.js index d10d9498..add346fc 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -89,6 +89,9 @@ module.exports = function() { db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) { console.log("test: ", connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel.length > 0, connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel) if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) { + Functions.setChromecastHost(socket.cookie_id, msg.guid, function(results) { + console.log("setChromecastHost: ", results); + }); socket.cookie_id = msg.guid; guid = msg.guid; socketid = msg.socket_id; @@ -96,6 +99,7 @@ module.exports = function() { if(msg.hasOwnProperty("channel")) { msg.channel = Functions.encodeChannelName(msg.channel); } + coll = msg.channel.toLowerCase();//.replace(/ /g,''); coll = Functions.removeEmojis(coll).toLowerCase(); coll = filter.clean(coll); diff --git a/server/routing/client/router.js b/server/routing/client/router.js index 76fbc1a2..81bd6529 100644 --- a/server/routing/client/router.js +++ b/server/routing/client/router.js @@ -34,12 +34,10 @@ try { } router.use(recaptcha.middleware.render, function(req, res, next) { - console.log("middleware render"); next(); // make sure we go to the next routes and don't stop here }); router.route('/:channel_name').get(function(req, res, next){ - console.log("channel_name get"); channel(req, res, next); }); @@ -49,12 +47,10 @@ router.route('/r/:base64data').get(function(req, res, next){ }); router.route('/').get(function(req, res, next){ - console.log("/ get"); root(req, res, next); }); router.route('/').post(function(req, res, next){ - console.log("/ post"); root(req, res, next); }); From 36618e34d492942c33b1fa98ee1fe4ef77e6386b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Mon, 4 Jun 2018 23:46:42 +0200 Subject: [PATCH 09/24] Forgot to export function --- server/handlers/functions.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/handlers/functions.js b/server/handlers/functions.js index 8e26009d..c72f8477 100644 --- a/server/handlers/functions.js +++ b/server/handlers/functions.js @@ -332,6 +332,7 @@ function removeSessionAdminPass(id, channel, callback) { }); } +module.exports.setChromecastHost = setChromecastHost; module.exports.decodeChannelName = decodeChannelName; module.exports.encodeChannelName = encodeChannelName; module.exports.isUrl = isUrl; From a44869a3cde6b91d551f79015db14eb693e75ee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Mon, 4 Jun 2018 23:48:40 +0200 Subject: [PATCH 10/24] Sending list with also --- server/handlers/functions.js | 3 ++- server/handlers/io.js | 15 +++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/handlers/functions.js b/server/handlers/functions.js index c72f8477..8839408c 100644 --- a/server/handlers/functions.js +++ b/server/handlers/functions.js @@ -253,7 +253,7 @@ function getSessionChatPass(id, callback) { } -function setChromecastHost(id, other_id, callback) { +function setChromecastHost(id, other_id, list, callback) { try { if(id == "empty" || id == undefined) { callback(); @@ -264,6 +264,7 @@ function setChromecastHost(id, other_id, callback) { return; }); } catch(e) { + console.log(e); callback(false); } } diff --git a/server/handlers/io.js b/server/handlers/io.js index add346fc..70af0ad0 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -89,7 +89,13 @@ module.exports = function() { db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) { console.log("test: ", connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel.length > 0, connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel) if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) { - Functions.setChromecastHost(socket.cookie_id, msg.guid, function(results) { + coll = msg.channel.toLowerCase();//.replace(/ /g,''); + coll = Functions.removeEmojis(coll).toLowerCase(); + coll = filter.clean(coll); + if(coll.indexOf("?") > -1){ + coll = coll.substring(0, coll.indexOf("?")); + } + Functions.setChromecastHost(socket.cookie_id, msg.guid, msg.channel, function(results) { console.log("setChromecastHost: ", results); }); socket.cookie_id = msg.guid; @@ -99,13 +105,6 @@ module.exports = function() { if(msg.hasOwnProperty("channel")) { msg.channel = Functions.encodeChannelName(msg.channel); } - - coll = msg.channel.toLowerCase();//.replace(/ /g,''); - coll = Functions.removeEmojis(coll).toLowerCase(); - coll = filter.clean(coll); - if(coll.indexOf("?") > -1){ - coll = coll.substring(0, coll.indexOf("?")); - } in_list = true; console.log("chromecast list", coll); chromecast_object = true; From 36cb2cd55a521a6d7b01c080ff0decce4ac59612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Mon, 4 Jun 2018 23:54:16 +0200 Subject: [PATCH 11/24] Logging more testing to see if data is set correctly --- server/handlers/functions.js | 1 + server/handlers/io.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/server/handlers/functions.js b/server/handlers/functions.js index 8839408c..f09c6b7e 100644 --- a/server/handlers/functions.js +++ b/server/handlers/functions.js @@ -294,6 +294,7 @@ function getSessionAdminUser(id, list, callback) { var userpass = ""; var adminpass = ""; if(d.length > 0) { + console.log(d); if(d.hasOwnProperty("chromecast") && d.chromecast) { getSessionAdminUser(d.id, list, callback); } else { diff --git a/server/handlers/io.js b/server/handlers/io.js index 70af0ad0..88779995 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -687,7 +687,9 @@ module.exports = function() { } db.collection(coll + "_settings").find(function(err, docs) { + console.log("trying to get pos in song"); Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) { + console.log("userpass, adminpass", userpass, adminpass); if(userpass != "" || obj.pass == undefined) { obj.pass = userpass; } From 394b73e5d0cf9bfbf24a002e86cc21046b1daa87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Mon, 4 Jun 2018 23:55:52 +0200 Subject: [PATCH 12/24] Forgot length of element --- server/handlers/functions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/handlers/functions.js b/server/handlers/functions.js index f09c6b7e..897d6bed 100644 --- a/server/handlers/functions.js +++ b/server/handlers/functions.js @@ -295,8 +295,8 @@ function getSessionAdminUser(id, list, callback) { var adminpass = ""; if(d.length > 0) { console.log(d); - if(d.hasOwnProperty("chromecast") && d.chromecast) { - getSessionAdminUser(d.id, list, callback); + if(d[0].hasOwnProperty("chromecast") && d[0].chromecast) { + getSessionAdminUser(d[0].id, list, callback); } else { if(d[0].userpass != undefined) userpass = d[0].userpass; if(d[0].adminpass != undefined) adminpass = d[0].adminpass; From 4e77585a27ecee4d3a57d0e17dfe8a1beef9dd72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Tue, 5 Jun 2018 10:24:09 +0200 Subject: [PATCH 13/24] Uncommented a feature --- server/handlers/functions.js | 3 ++- server/handlers/io.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/server/handlers/functions.js b/server/handlers/functions.js index 897d6bed..72ba3c3f 100644 --- a/server/handlers/functions.js +++ b/server/handlers/functions.js @@ -286,6 +286,7 @@ function setSessionUserPass(id, userpass, list, callback) { function getSessionAdminUser(id, list, callback) { try { + console.log(id); if(id == "empty" || id == undefined) { callback("", "", false); return; @@ -294,7 +295,7 @@ function getSessionAdminUser(id, list, callback) { var userpass = ""; var adminpass = ""; if(d.length > 0) { - console.log(d); + console.log(id, d); if(d[0].hasOwnProperty("chromecast") && d[0].chromecast) { getSessionAdminUser(d[0].id, list, callback); } else { diff --git a/server/handlers/io.js b/server/handlers/io.js index 88779995..536b258e 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -28,6 +28,7 @@ module.exports = function() { } catch(e) { socket.cookie_id = "empty"; } + console.log("socket.cookie_id at start", socket.cookie_id); socket.zoff_id = socket.id; socket.emit("get_list"); @@ -95,9 +96,9 @@ module.exports = function() { if(coll.indexOf("?") > -1){ coll = coll.substring(0, coll.indexOf("?")); } - Functions.setChromecastHost(socket.cookie_id, msg.guid, msg.channel, function(results) { + /*Functions.setChromecastHost(socket.cookie_id, msg.guid, msg.channel, function(results) { console.log("setChromecastHost: ", results); - }); + });*/ socket.cookie_id = msg.guid; guid = msg.guid; socketid = msg.socket_id; From 94182ddaf769acf016198371ce4efc60546c6e17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Tue, 5 Jun 2018 10:35:25 +0200 Subject: [PATCH 14/24] Trying to check useragent --- server/apps/client.js | 1 + server/handlers/io.js | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/server/apps/client.js b/server/apps/client.js index c3c32214..063ad599 100755 --- a/server/apps/client.js +++ b/server/apps/client.js @@ -71,6 +71,7 @@ app.get('/robots.txt', function (req, res) { }); app.use(function (req, res, next) { + console.log("User agent", req.get("User-Agent")); var cookie = req.cookies._uI; if (cookie === undefined) { var user_name = Functions.hash_pass(Functions.rndName(uniqid.time(), 15)); diff --git a/server/handlers/io.js b/server/handlers/io.js index 536b258e..a6a7f2f3 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -22,6 +22,7 @@ var db = require(pathThumbnails + '/handlers/db.js'); module.exports = function() { io.on('connection', function(socket){ try { + console.log("Full cookies", cookie.parse(socket.handshake.headers.cookie)); var parsedCookies = cookie.parse(socket.handshake.headers.cookie); socket.cookie_id = parsedCookies["_uI"]; //return socket.guid; @@ -88,6 +89,7 @@ module.exports = function() { msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel") && typeof(msg.guid) == "string" && typeof(msg.channel) == "string" && typeof(msg.socket_id) == "string" && msg.channel != "") { db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) { + console.log("another error"); console.log("test: ", connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel.length > 0, connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel) if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) { coll = msg.channel.toLowerCase();//.replace(/ /g,''); @@ -99,7 +101,7 @@ module.exports = function() { /*Functions.setChromecastHost(socket.cookie_id, msg.guid, msg.channel, function(results) { console.log("setChromecastHost: ", results); });*/ - socket.cookie_id = msg.guid; + //socket.cookie_id = msg.guid; guid = msg.guid; socketid = msg.socket_id; socket.zoff_id = socketid; @@ -114,14 +116,14 @@ module.exports = function() { }); } } catch(e) { - console.log(e); + console.log("this is the crash" + e); return; } }); socket.on("get_id", function() { console.log("gotten request from mobile", Functions.getSession(socket)); - socket.emit("id_chromecast", guid); + socket.emit("id_chromecast", Functions.getSession(socket)); }); socket.on("error_video", function(msg) { From 051d5df1ac9b438de86b78c2f8bf8961a076053f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Tue, 5 Jun 2018 10:37:12 +0200 Subject: [PATCH 15/24] Trying a failsafe on the cookie_id --- server/handlers/functions.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/handlers/functions.js b/server/handlers/functions.js index 72ba3c3f..6b6e5890 100644 --- a/server/handlers/functions.js +++ b/server/handlers/functions.js @@ -62,6 +62,7 @@ function getSession(socket) { var cookie = require("cookie"); var parsedCookies = cookie.parse(socket.handshake.headers.cookie); return parsedCookies["_uI"];*/ + if(socket.cookie_id == undefined) throw "Undefined error"); return socket.cookie_id; } catch(e) { return "empty"; From c4bacf566385ca6655b7d7a50a6a3d7b2d63a3c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Tue, 5 Jun 2018 10:38:09 +0200 Subject: [PATCH 16/24] Typo.. --- server/handlers/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/handlers/functions.js b/server/handlers/functions.js index 6b6e5890..3ffb1d54 100644 --- a/server/handlers/functions.js +++ b/server/handlers/functions.js @@ -62,7 +62,7 @@ function getSession(socket) { var cookie = require("cookie"); var parsedCookies = cookie.parse(socket.handshake.headers.cookie); return parsedCookies["_uI"];*/ - if(socket.cookie_id == undefined) throw "Undefined error"); + if(socket.cookie_id == undefined) throw "Undefined error"; return socket.cookie_id; } catch(e) { return "empty"; From 1476c8b0bc5e8fdc466b56e9c37069dec5c775cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Tue, 5 Jun 2018 10:43:16 +0200 Subject: [PATCH 17/24] Trying to avoid chromecast fetching position --- server/handlers/io.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server/handlers/io.js b/server/handlers/io.js index a6a7f2f3..3efd41ff 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -22,14 +22,12 @@ var db = require(pathThumbnails + '/handlers/db.js'); module.exports = function() { io.on('connection', function(socket){ try { - console.log("Full cookies", cookie.parse(socket.handshake.headers.cookie)); var parsedCookies = cookie.parse(socket.handshake.headers.cookie); socket.cookie_id = parsedCookies["_uI"]; //return socket.guid; } catch(e) { socket.cookie_id = "empty"; } - console.log("socket.cookie_id at start", socket.cookie_id); socket.zoff_id = socket.id; socket.emit("get_list"); @@ -89,7 +87,7 @@ module.exports = function() { msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel") && typeof(msg.guid) == "string" && typeof(msg.channel) == "string" && typeof(msg.socket_id) == "string" && msg.channel != "") { db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) { - console.log("another error"); + console.log("another error", err); console.log("test: ", connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel.length > 0, connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel) if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) { coll = msg.channel.toLowerCase();//.replace(/ /g,''); @@ -116,7 +114,7 @@ module.exports = function() { }); } } catch(e) { - console.log("this is the crash" + e); + console.log("this is the crash", e); return; } }); @@ -688,7 +686,10 @@ module.exports = function() { socket.emit('update_required', result); return; } - + if(chromecast_object) { + console.log("chromecast object", Functions.getSession(socket)); + return; + } db.collection(coll + "_settings").find(function(err, docs) { console.log("trying to get pos in song"); Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) { From 764abdd19b86f551ada1ac51e9b1f709eb9013d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Tue, 5 Jun 2018 10:47:10 +0200 Subject: [PATCH 18/24] Switching two variables around --- server/handlers/io.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/handlers/io.js b/server/handlers/io.js index 3efd41ff..907dd01d 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -89,7 +89,7 @@ module.exports = function() { db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) { console.log("another error", err); console.log("test: ", connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel.length > 0, connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel) - if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) { + if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.socket_id) > -1) { coll = msg.channel.toLowerCase();//.replace(/ /g,''); coll = Functions.removeEmojis(coll).toLowerCase(); coll = filter.clean(coll); @@ -649,6 +649,7 @@ module.exports = function() { socket.on('pos', function(obj) { + console.log("pos object", obj); if(obj != undefined && obj.hasOwnProperty("channel") && obj.channel.indexOf("?") > -1){ var _list = obj.channel.substring(0, obj.channel.indexOf("?")); obj.channel = _list; From abe6d1f5bbcf2db62668c4889c3d0e755dd0372f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Tue, 5 Jun 2018 10:52:45 +0200 Subject: [PATCH 19/24] Trying the flowthrough --- server/apps/client.js | 1 - server/handlers/functions.js | 1 + server/handlers/io.js | 4 ++-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/apps/client.js b/server/apps/client.js index 063ad599..c3c32214 100755 --- a/server/apps/client.js +++ b/server/apps/client.js @@ -71,7 +71,6 @@ app.get('/robots.txt', function (req, res) { }); app.use(function (req, res, next) { - console.log("User agent", req.get("User-Agent")); var cookie = req.cookies._uI; if (cookie === undefined) { var user_name = Functions.hash_pass(Functions.rndName(uniqid.time(), 15)); diff --git a/server/handlers/functions.js b/server/handlers/functions.js index 3ffb1d54..1e8db852 100644 --- a/server/handlers/functions.js +++ b/server/handlers/functions.js @@ -256,6 +256,7 @@ function getSessionChatPass(id, callback) { function setChromecastHost(id, other_id, list, callback) { try { + console.log("settingChromecastHost: ", socket.cookie_id, msg.guid); if(id == "empty" || id == undefined) { callback(); return; diff --git a/server/handlers/io.js b/server/handlers/io.js index 907dd01d..72391625 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -96,9 +96,9 @@ module.exports = function() { if(coll.indexOf("?") > -1){ coll = coll.substring(0, coll.indexOf("?")); } - /*Functions.setChromecastHost(socket.cookie_id, msg.guid, msg.channel, function(results) { + Functions.setChromecastHost(socket.cookie_id, msg.guid, msg.channel, function(results) { console.log("setChromecastHost: ", results); - });*/ + }); //socket.cookie_id = msg.guid; guid = msg.guid; socketid = msg.socket_id; From 2560450a6dc7e403e5092f09eacadd766a506910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Tue, 5 Jun 2018 11:02:03 +0200 Subject: [PATCH 20/24] Sending more values to get chromecast to think it is the mobile phone --- server/handlers/functions.js | 2 +- server/handlers/io.js | 7 ++++--- server/public/assets/js/functions.js | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/server/handlers/functions.js b/server/handlers/functions.js index 1e8db852..f7b73c49 100644 --- a/server/handlers/functions.js +++ b/server/handlers/functions.js @@ -256,7 +256,7 @@ function getSessionChatPass(id, callback) { function setChromecastHost(id, other_id, list, callback) { try { - console.log("settingChromecastHost: ", socket.cookie_id, msg.guid); + console.log("settingChromecastHost: ", id, other_id); if(id == "empty" || id == undefined) { callback(); return; diff --git a/server/handlers/io.js b/server/handlers/io.js index 72391625..f4cfdc1c 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -89,14 +89,14 @@ module.exports = function() { db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) { console.log("another error", err); console.log("test: ", connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel.length > 0, connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel) - if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.socket_id) > -1) { + if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) { coll = msg.channel.toLowerCase();//.replace(/ /g,''); coll = Functions.removeEmojis(coll).toLowerCase(); coll = filter.clean(coll); if(coll.indexOf("?") > -1){ coll = coll.substring(0, coll.indexOf("?")); } - Functions.setChromecastHost(socket.cookie_id, msg.guid, msg.channel, function(results) { + Functions.setChromecastHost(socket.cookie_id, msg.socketid, msg.channel, function(results) { console.log("setChromecastHost: ", results); }); //socket.cookie_id = msg.guid; @@ -121,7 +121,7 @@ module.exports = function() { socket.on("get_id", function() { console.log("gotten request from mobile", Functions.getSession(socket)); - socket.emit("id_chromecast", Functions.getSession(socket)); + socket.emit("id_chromecast", {cookie_id: Functions.getSession(socket), guid: guid}); }); socket.on("error_video", function(msg) { @@ -687,6 +687,7 @@ module.exports = function() { socket.emit('update_required', result); return; } + if(coll == undefined) return; if(chromecast_object) { console.log("chromecast object", Functions.getSession(socket)); return; diff --git a/server/public/assets/js/functions.js b/server/public/assets/js/functions.js index 91677306..7ae15d0d 100644 --- a/server/public/assets/js/functions.js +++ b/server/public/assets/js/functions.js @@ -450,7 +450,7 @@ function get_list_listener(){ }); socket.on("id_chromecast", function(msg) { chromecast_specs_sent = true; - castSession.sendMessage("urn:x-cast:zoff.me", {type: "mobilespecs", guid: msg, socketid: socket.id, channel: chan.toLowerCase()}) + castSession.sendMessage("urn:x-cast:zoff.me", {type: "mobilespecs", guid: msg.guid, socketid: msg.cookie_id, channel: chan.toLowerCase()}) }) } From 88a3ecd108756319b0e3d6507cf0b17eac5a1c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Tue, 5 Jun 2018 11:04:05 +0200 Subject: [PATCH 21/24] Typo in variable-name --- server/handlers/io.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/handlers/io.js b/server/handlers/io.js index f4cfdc1c..d7cd3efc 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -96,7 +96,7 @@ module.exports = function() { if(coll.indexOf("?") > -1){ coll = coll.substring(0, coll.indexOf("?")); } - Functions.setChromecastHost(socket.cookie_id, msg.socketid, msg.channel, function(results) { + Functions.setChromecastHost(socket.cookie_id, msg.socket_id, msg.channel, function(results) { console.log("setChromecastHost: ", results); }); //socket.cookie_id = msg.guid; From a3aea4902b7f097aa8c4ba657d7a4cdf8846d0ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Tue, 5 Jun 2018 11:05:47 +0200 Subject: [PATCH 22/24] Allowing chromecast to fetch position --- server/handlers/io.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/server/handlers/io.js b/server/handlers/io.js index d7cd3efc..2906bcef 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -688,10 +688,6 @@ module.exports = function() { return; } if(coll == undefined) return; - if(chromecast_object) { - console.log("chromecast object", Functions.getSession(socket)); - return; - } db.collection(coll + "_settings").find(function(err, docs) { console.log("trying to get pos in song"); Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) { From f9c95efe5de4037fc43bf76aa74bff3b81ba5bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Tue, 5 Jun 2018 11:07:49 +0200 Subject: [PATCH 23/24] Created a forever loop --- server/handlers/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/handlers/functions.js b/server/handlers/functions.js index f7b73c49..5c42d5f1 100644 --- a/server/handlers/functions.js +++ b/server/handlers/functions.js @@ -261,7 +261,7 @@ function setChromecastHost(id, other_id, list, callback) { callback(); return; } - connected_db.collection(id).update({_id: list}, {"chromecast": true, id: id}, {upsert: true}, function(e, docs) { + connected_db.collection(id).update({_id: list}, {"chromecast": true, id: other_id}, {upsert: true}, function(e, docs) { callback(true); return; }); From 55bc1593af262f2c75722026c34a198c23aeb775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Tue, 5 Jun 2018 11:55:22 +0200 Subject: [PATCH 24/24] Cleaning up logs, now working chromecast on private channel --- server/handlers/functions.js | 4 ---- server/handlers/io.js | 13 ------------- 2 files changed, 17 deletions(-) diff --git a/server/handlers/functions.js b/server/handlers/functions.js index 5c42d5f1..52ab33bc 100644 --- a/server/handlers/functions.js +++ b/server/handlers/functions.js @@ -256,7 +256,6 @@ function getSessionChatPass(id, callback) { function setChromecastHost(id, other_id, list, callback) { try { - console.log("settingChromecastHost: ", id, other_id); if(id == "empty" || id == undefined) { callback(); return; @@ -266,7 +265,6 @@ function setChromecastHost(id, other_id, list, callback) { return; }); } catch(e) { - console.log(e); callback(false); } } @@ -288,7 +286,6 @@ function setSessionUserPass(id, userpass, list, callback) { function getSessionAdminUser(id, list, callback) { try { - console.log(id); if(id == "empty" || id == undefined) { callback("", "", false); return; @@ -297,7 +294,6 @@ function getSessionAdminUser(id, list, callback) { var userpass = ""; var adminpass = ""; if(d.length > 0) { - console.log(id, d); if(d[0].hasOwnProperty("chromecast") && d[0].chromecast) { getSessionAdminUser(d[0].id, list, callback); } else { diff --git a/server/handlers/io.js b/server/handlers/io.js index 2906bcef..ed2a3166 100644 --- a/server/handlers/io.js +++ b/server/handlers/io.js @@ -79,16 +79,11 @@ module.exports = function() { }); socket.on('chromecast', function(msg) { - console.log("chromecast event", msg); - console.log(Functions.getSession(socket)); - console.log("cookie_id", socket.cookie_id); try { if(typeof(msg) == "object" && msg.hasOwnProperty("guid") && msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel") && typeof(msg.guid) == "string" && typeof(msg.channel) == "string" && typeof(msg.socket_id) == "string" && msg.channel != "") { db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) { - console.log("another error", err); - console.log("test: ", connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel.length > 0, connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel) if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) { coll = msg.channel.toLowerCase();//.replace(/ /g,''); coll = Functions.removeEmojis(coll).toLowerCase(); @@ -97,7 +92,6 @@ module.exports = function() { coll = coll.substring(0, coll.indexOf("?")); } Functions.setChromecastHost(socket.cookie_id, msg.socket_id, msg.channel, function(results) { - console.log("setChromecastHost: ", results); }); //socket.cookie_id = msg.guid; guid = msg.guid; @@ -107,20 +101,17 @@ module.exports = function() { msg.channel = Functions.encodeChannelName(msg.channel); } in_list = true; - console.log("chromecast list", coll); chromecast_object = true; socket.join(coll); } }); } } catch(e) { - console.log("this is the crash", e); return; } }); socket.on("get_id", function() { - console.log("gotten request from mobile", Functions.getSession(socket)); socket.emit("id_chromecast", {cookie_id: Functions.getSession(socket), guid: guid}); }); @@ -406,7 +397,6 @@ module.exports = function() { socket.on('end', function(obj) { - console.log("end event", obj); if(obj.hasOwnProperty("channel") && obj.channel.indexOf("?") > -1){ var _list = obj.channel.substring(0, obj.channel.indexOf("?")); obj.channel = _list; @@ -649,7 +639,6 @@ module.exports = function() { socket.on('pos', function(obj) { - console.log("pos object", obj); if(obj != undefined && obj.hasOwnProperty("channel") && obj.channel.indexOf("?") > -1){ var _list = obj.channel.substring(0, obj.channel.indexOf("?")); obj.channel = _list; @@ -689,9 +678,7 @@ module.exports = function() { } if(coll == undefined) return; db.collection(coll + "_settings").find(function(err, docs) { - console.log("trying to get pos in song"); Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) { - console.log("userpass, adminpass", userpass, adminpass); if(userpass != "" || obj.pass == undefined) { obj.pass = userpass; }