mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 16:46:31 +00:00
now with background polling and indication of online hosts
This commit is contained in:
parent
a11b097dde
commit
6b8ac65d7f
@ -162,6 +162,9 @@ main {
|
||||
-moz-border-radius: 10px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.host-cell-inactive {
|
||||
border: 3px solid red;
|
||||
}
|
||||
.host-cell:hover {
|
||||
cursor: pointer;
|
||||
color: #000 !important;
|
||||
|
@ -49,6 +49,35 @@ function restoreUiAfterNaClLoad() {
|
||||
$('#naclSpinner').hide();
|
||||
$('#loadingSpinner').css('display', 'none');
|
||||
showHostsAndSettingsMode();
|
||||
for(hostUID in hosts) {
|
||||
beginBackgroundPollingOfHost(hosts[hostUID]);
|
||||
}
|
||||
}
|
||||
|
||||
function beginBackgroundPollingOfHost(host) {
|
||||
$("#hostgrid-" + host.serverUid).addClass('host-cell-inactive');
|
||||
// for each host, first assume it's inactive.
|
||||
|
||||
host.initialPing(function () { // initial attempt was a success
|
||||
$("#hostgrid-" + host.serverUid).removeClass('host-cell-inactive');
|
||||
window.setInterval(function() {
|
||||
// every 5 seconds, poll at the address we know it was live at
|
||||
host.refreshServerInfoAtAddress(host.address).then(function (onSuccess){
|
||||
$("#hostgrid-" + host.serverUid).removeClass('host-cell-inactive');
|
||||
}, function (onFailure) {
|
||||
$("#hostgrid-" + host.serverUid).addClass('host-cell-inactive');
|
||||
});
|
||||
}, 5000);
|
||||
}, function () { // initial attempt was a failure
|
||||
$("#hostgrid-" + host.serverUid).addClass('host-cell-inactive');
|
||||
window.setInterval(function() {
|
||||
if(host.refreshServerInfoAtAddress(host.address)) {
|
||||
$("#hostgrid-" + host.serverUid).removeClass('host-cell-inactive');
|
||||
} else {
|
||||
$("#hostgrid-" + host.serverUid).addClass('host-cell-inactive');
|
||||
}
|
||||
}, 5000);
|
||||
});
|
||||
}
|
||||
|
||||
function snackbarLog(givenMessage) {
|
||||
|
@ -90,9 +90,10 @@ NvHTTP.prototype = {
|
||||
// try HTTPS first
|
||||
return sendMessage('openUrl', [ 'https://' + givenAddress + ':47984' + '/serverinfo?' + _self._buildUidStr(), false]).then(function(ret) {
|
||||
if (!_self._parseServerInfo(ret)) { // if that fails
|
||||
console.log('Failed to parse serverinfo from HTTPS, falling back to HTTP');
|
||||
// try HTTP as a failover. Useful to clients who aren't paired yet
|
||||
return sendMessage('openUrl', [ 'http://' + givenAddress + ':47989' + '/serverinfo?' + _self._buildUidStr(), false]).then(function(retHttp) {
|
||||
_self._parseServerInfo(retHttp);
|
||||
return _self._parseServerInfo(retHttp);
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -147,6 +148,11 @@ NvHTTP.prototype = {
|
||||
if($root.attr("status_code") != 200) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(_self.serverUid != $root.find('uniqueid').text().trim() && _self.serverUid != null) {
|
||||
// if we received a UID that isn't the one we expected, fail.
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log('parsing server info: ');
|
||||
console.log($root);
|
||||
|
Loading…
x
Reference in New Issue
Block a user