mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 16:46:31 +00:00
Prevent pairing if already in game
This commit is contained in:
parent
2682ab6530
commit
ed03b8e117
@ -108,6 +108,8 @@ function pairPushed() {
|
||||
snackbarLog('Pairing failed');
|
||||
$('#pairButton')[0].innerHTML = 'Pairing Failed';
|
||||
document.getElementById('pairingDialogText').innerHTML = 'Error: Pairing failed';
|
||||
if (api.currentGame != 0)
|
||||
snackbarLog(target + ' is already in game. Cannot pair!');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -36,10 +36,22 @@ function NvHTTP(address, clientUid) {
|
||||
NvHTTP.prototype = {
|
||||
refreshServerInfo: function () {
|
||||
return sendMessage('openUrl', [ _self._baseUrlHttps + '/serverinfo?' + _self._buildUidStr()]).then(function(ret) {
|
||||
$xml = _self._parseXML(ret);
|
||||
$root = $xml.find('root')
|
||||
if (!_self._parseServerInfo(ret)) {
|
||||
return sendMessage('openUrl', [ _self._baseUrlHttp + '/serverinfo?' + _self._buildUidStr()]).then(function(retHttp) {
|
||||
_self._parseServerInfo(retHttp);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_parseServerInfo: function(xmlStr) {
|
||||
$xml = _self._parseXML(xmlStr);
|
||||
$root = $xml.find('root');
|
||||
|
||||
if($root.attr("status_code") != 200) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
@ -50,8 +62,8 @@ NvHTTP.prototype = {
|
||||
if ($root.find("state").text().trim().endsWith("_SERVER_AVAILABLE")) {
|
||||
_self.currentGame = 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
getAppById: function (appId) {
|
||||
@ -167,6 +179,9 @@ NvHTTP.prototype = {
|
||||
if (_self.paired)
|
||||
return true;
|
||||
|
||||
if (_self.currentGame != 0)
|
||||
return false;
|
||||
|
||||
return sendMessage('pair', [_self.serverMajorVersion, _self.address, randomNumber]).then(function (pairStatus) {
|
||||
return sendMessage('openUrl', [_self._baseUrlHttps + '/pair?uniqueid=' + _self.clientUid + '&devicename=roth&updateState=1&phrase=pairchallenge']).then(function (ret) {
|
||||
$xml = _self._parseXML(ret);
|
||||
|
Loading…
x
Reference in New Issue
Block a user