mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 08:36:42 +00:00
parent
e555bd8282
commit
bc49cff3c2
@ -89,6 +89,7 @@ function pairPushed() {
|
|||||||
api = new NvHTTP(target, myUniqueid);
|
api = new NvHTTP(target, myUniqueid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
api.refreshServerInfoUnpaired().then(function (ret) {
|
api.refreshServerInfoUnpaired().then(function (ret) {
|
||||||
|
|
||||||
if(api.currentGame != 0) { // make sure host isn't already in a game
|
if(api.currentGame != 0) { // make sure host isn't already in a game
|
||||||
@ -96,41 +97,50 @@ function pairPushed() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#pairButton')[0].innerHTML = 'Pairing...';
|
api.refreshServerInfo().then(function (ret) {
|
||||||
snackbarLog('Attempting pair to: ' + target);
|
if(api.paired) { // don't pair if you don't have to
|
||||||
var randomNumber = String("0000" + (Math.random()*10000|0)).slice(-4);
|
snackbarLog('already paired with ' + target + '!');
|
||||||
var pairingDialog = document.querySelector('#pairingDialog');
|
return;
|
||||||
document.getElementById('pairingDialogText').innerHTML =
|
} else { // we're not already paired. pair now.
|
||||||
'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', [api.serverMajorVersion, target, randomNumber]).then(function (ret3) {
|
$('#pairButton')[0].innerHTML = 'Pairing...';
|
||||||
console.log('"pair" call returned.');
|
snackbarLog('Attempting pair to: ' + target);
|
||||||
console.log(ret3);
|
var randomNumber = String("0000" + (Math.random()*10000|0)).slice(-4);
|
||||||
if (ret3 === 0) { // pairing was successful. save this host.
|
var pairingDialog = document.querySelector('#pairingDialog');
|
||||||
$('#pairButton')[0].innerHTML = 'Paired';
|
document.getElementById('pairingDialogText').innerHTML =
|
||||||
snackbarLog('Pairing successful');
|
'Please enter the number ' + randomNumber + ' on the GFE dialog on the computer. This dialog will be dismissed once complete';
|
||||||
pairingDialog.close();
|
pairingDialog.showModal();
|
||||||
var hostSelect = $('#selectHost')[0];
|
console.log('sending pairing request to ' + target + ' with random number ' + randomNumber);
|
||||||
for(var i = 0; i < hostSelect.length; i++) { // check if we already have the host.
|
|
||||||
if (hostSelect.options[i].value == target) return;
|
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.
|
||||||
|
$('#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');
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
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);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user