fixed pairing for new GFE

This commit is contained in:
= 2016-03-31 17:17:37 -04:00
parent 034d2ebf9d
commit 08554e9c57
2 changed files with 57 additions and 25 deletions

View File

@ -85,6 +85,9 @@ function pairPushed() {
console.log("User wants to pair, and we still have no cert. Problem = very yes.");
return;
}
if(!api || !api.paired) {
api = new NvHTTP(target, myUniqueid);
}
$('#pairButton')[0].innerHTML = 'Pairing...';
snackbarLog('Attempting pair to: ' + target);
@ -94,7 +97,9 @@ function pairPushed() {
'Please enter the number ' + randomNumber + ' on the GFE dialog on the computer. This dialog will be dismissed once complete';
pairingDialog.showModal();
console.log('sending pairing request to ' + target + ' with random number ' + randomNumber);
sendMessage('pair', [target, randomNumber]).then(function (ret3) {
api.refreshServerInfoUnpaired().then(function (ret) {
sendMessage('pair', [api.serverMajorVersion, target, randomNumber]).then(function (ret3) {
console.log('"pair" call returned.');
console.log(ret3);
if (ret3 === 0) { // pairing was successful. save this host.
@ -121,6 +126,8 @@ function pairPushed() {
}
console.log("pairing attempt returned: " + ret3);
});
});
}
function pairingPopupCanceled() {
@ -137,6 +144,11 @@ function showAppsPushed() {
}
api.refreshServerInfo().then(function (ret) {
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
var opt = document.createElement('option');
opt.appendChild(document.createTextNode(appList[i]));

View File

@ -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) {
return _self.getAppList().then(function (list) {
var retApp = null;