Skip to content

Commit

Permalink
Adding remote session status check. Addresses #633
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsielicki committed Aug 24, 2016
1 parent f566ced commit 22b71ad
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 18 deletions.
66 changes: 48 additions & 18 deletions web-server/js/slycat-remotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
}

Expand Down
20 changes: 20 additions & 0 deletions web-server/js/slycat-web-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 22b71ad

Please sign in to comment.