mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-18 00:56:38 +00:00
fixed pairing for new GFE
This commit is contained in:
parent
034d2ebf9d
commit
08554e9c57
@ -85,6 +85,9 @@ function pairPushed() {
|
|||||||
console.log("User wants to pair, and we still have no cert. Problem = very yes.");
|
console.log("User wants to pair, and we still have no cert. Problem = very yes.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(!api || !api.paired) {
|
||||||
|
api = new NvHTTP(target, myUniqueid);
|
||||||
|
}
|
||||||
|
|
||||||
$('#pairButton')[0].innerHTML = 'Pairing...';
|
$('#pairButton')[0].innerHTML = 'Pairing...';
|
||||||
snackbarLog('Attempting pair to: ' + target);
|
snackbarLog('Attempting pair to: ' + target);
|
||||||
@ -94,33 +97,37 @@ function pairPushed() {
|
|||||||
'Please enter the number ' + randomNumber + ' on the GFE dialog on the computer. This dialog will be dismissed once complete';
|
'Please enter the number ' + randomNumber + ' on the GFE dialog on the computer. This dialog will be dismissed once complete';
|
||||||
pairingDialog.showModal();
|
pairingDialog.showModal();
|
||||||
console.log('sending pairing request to ' + target + ' with random number ' + randomNumber);
|
console.log('sending pairing request to ' + target + ' with random number ' + randomNumber);
|
||||||
sendMessage('pair', [target, randomNumber]).then(function (ret3) {
|
|
||||||
console.log('"pair" call returned.');
|
|
||||||
console.log(ret3);
|
|
||||||
if (ret3 === 0) { // pairing was successful. save this host.
|
|
||||||
$('#pairButton')[0].innerHTML = 'Paired';
|
|
||||||
snackbarLog('Pairing successful');
|
|
||||||
pairingDialog.close();
|
|
||||||
var hostSelect = $('#selectHost')[0];
|
|
||||||
for(var i = 0; i < hostSelect.length; i++) { // check if we already have the host.
|
|
||||||
if (hostSelect.options[i].value == target) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var opt = document.createElement('option');
|
api.refreshServerInfoUnpaired().then(function (ret) {
|
||||||
opt.appendChild(document.createTextNode(target));
|
sendMessage('pair', [api.serverMajorVersion, target, randomNumber]).then(function (ret3) {
|
||||||
opt.value = target;
|
console.log('"pair" call returned.');
|
||||||
$('#selectHost')[0].appendChild(opt);
|
console.log(ret3);
|
||||||
hosts.push(target);
|
if (ret3 === 0) { // pairing was successful. save this host.
|
||||||
saveHosts();
|
$('#pairButton')[0].innerHTML = 'Paired';
|
||||||
// move directly on to retrieving the apps list.
|
snackbarLog('Pairing successful');
|
||||||
showAppsPushed();
|
pairingDialog.close();
|
||||||
} else {
|
var hostSelect = $('#selectHost')[0];
|
||||||
snackbarLog('Pairing failed');
|
for(var i = 0; i < hostSelect.length; i++) { // check if we already have the host.
|
||||||
$('#pairButton')[0].innerHTML = 'Pairing Failed';
|
if (hostSelect.options[i].value == target) return;
|
||||||
document.getElementById('pairingDialogText').innerHTML = 'Error: Pairing failed with code: ' + ret3;
|
}
|
||||||
}
|
|
||||||
console.log("pairing attempt returned: " + ret3);
|
var opt = document.createElement('option');
|
||||||
|
opt.appendChild(document.createTextNode(target));
|
||||||
|
opt.value = target;
|
||||||
|
$('#selectHost')[0].appendChild(opt);
|
||||||
|
hosts.push(target);
|
||||||
|
saveHosts();
|
||||||
|
// move directly on to retrieving the apps list.
|
||||||
|
showAppsPushed();
|
||||||
|
} else {
|
||||||
|
snackbarLog('Pairing failed');
|
||||||
|
$('#pairButton')[0].innerHTML = 'Pairing Failed';
|
||||||
|
document.getElementById('pairingDialogText').innerHTML = 'Error: Pairing failed with code: ' + ret3;
|
||||||
|
}
|
||||||
|
console.log("pairing attempt returned: " + ret3);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function pairingPopupCanceled() {
|
function pairingPopupCanceled() {
|
||||||
@ -137,6 +144,11 @@ function showAppsPushed() {
|
|||||||
}
|
}
|
||||||
api.refreshServerInfo().then(function (ret) {
|
api.refreshServerInfo().then(function (ret) {
|
||||||
api.getAppList().then(function (appList) {
|
api.getAppList().then(function (appList) {
|
||||||
|
if ($('#selectGame').has('option').length > 0 ) {
|
||||||
|
// there was already things in the dropdown. Clear it, then add the new ones.
|
||||||
|
// Most likely, the user just hit the 'retrieve app list' button again
|
||||||
|
$('#selectGame').empty();
|
||||||
|
}
|
||||||
for(var i = 0; i < appList.length; i++) { // programmatically add each app
|
for(var i = 0; i < appList.length; i++) { // programmatically add each app
|
||||||
var opt = document.createElement('option');
|
var opt = document.createElement('option');
|
||||||
opt.appendChild(document.createTextNode(appList[i]));
|
opt.appendChild(document.createTextNode(appList[i]));
|
||||||
|
@ -53,6 +53,26 @@ NvHTTP.prototype = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
refreshServerInfoUnpaired: function () {
|
||||||
|
return sendMessage('openUrl', [_self._baseUrlHttp+'/serverinfo?'+_self._buildUidStr()]).then(function(ret) {
|
||||||
|
$xml = _self._parseXML(ret);
|
||||||
|
$root = $xml.find('root')
|
||||||
|
|
||||||
|
if($root.attr("status_code") == 200) {
|
||||||
|
_self.paired = $root.find("PairStatus").text().trim() == 1;
|
||||||
|
_self.currentGame = parseInt($root.find("currentgame").text().trim(), 10);
|
||||||
|
_self.serverMajorVersion = parseInt($root.find("appversion").text().trim().substring(0, 1), 10);
|
||||||
|
|
||||||
|
// GFE 2.8 started keeping currentgame set to the last game played. As a result, it no longer
|
||||||
|
// has the semantics that its name would indicate. To contain the effects of this change as much
|
||||||
|
// as possible, we'll force the current game to zero if the server isn't in a streaming session.
|
||||||
|
if ($root.find("state").text().trim().endsWith("_SERVER_AVAILABLE")) {
|
||||||
|
_self.currentGame = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
getAppById: function (appId) {
|
getAppById: function (appId) {
|
||||||
return _self.getAppList().then(function (list) {
|
return _self.getAppList().then(function (list) {
|
||||||
var retApp = null;
|
var retApp = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user