diff --git a/web-server/js/slycat-remotes.js b/web-server/js/slycat-remotes.js index 10872fce0..1b4f1eda9 100644 --- a/web-server/js/slycat-remotes.js +++ b/web-server/js/slycat-remotes.js @@ -62,31 +62,61 @@ define("slycat-remotes", ["slycat-server-root", "slycat-web-client", "knockout", var pool = {}; - pool.get_remote = function(params) + pool.check_remote = function(params) { - if(params.hostname in remotes) - { - if(params.success) - params.success(params.hostname); - return; - } - - module.login( - { + client.get_remotes({ hostname: params.hostname, - title: params.title, - message: params.message, - success: function(sid) + success: function(result) { - remotes[params.hostname] = sid; if(params.success) - params.success(params.hostname); + params.success(result); }, - cancel: function() + error: function(request, status, reason_phrase) + { + if(params.error) + params.error(request, status, reason_phrase); + } + }); + } + + pool.get_remote = function(params) + { + pool.check_remote({ + hostname: params.hostname, + get_remote_params: params, + success: function(result) { - if(params.cancel) - params.cancel(); + if(result.status) + { + if(params.success) + params.success(params.hostname); + return; + } + else + { + module.login( + { + hostname: params.hostname, + title: params.title, + message: params.message, + success: function(sid) + { + if(params.success) + params.success(params.hostname); + }, + cancel: function() + { + if(params.cancel) + params.cancel(); + }, + }); + } }, + error: function(request, status, reason_phrase) + { + console.log("Unable to check status of remote session."); + return; + } }); } diff --git a/web-server/js/slycat-web-client.js b/web-server/js/slycat-web-client.js index 8c227fa15..a41e89a04 100644 --- a/web-server/js/slycat-web-client.js +++ b/web-server/js/slycat-web-client.js @@ -543,6 +543,26 @@ define("slycat-web-client", ["slycat-server-root", "jquery", "URI"], function(se }); } + module.get_remotes = function(params) + { + $.ajax( + { + dataType: "json", + type: "GET", + url: server_root + "remotes/" + params.hostname, + success: function(result) + { + if(params.success) + params.success(result); + }, + error: function(request, status, reason_phrase) + { + if(params.error) + params.error(request, status, reason_phrase); + } + }); + }; + module.get_remote_video_status = function(params) { $.ajax(