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;