prevent pairing if already paired

this closes #25
This commit is contained in:
R. Aidan Campbell 2016-04-03 10:52:07 -04:00
parent e555bd8282
commit bc49cff3c2

View File

@ -89,6 +89,7 @@ function pairPushed() {
api = new NvHTTP(target, myUniqueid);
}
api.refreshServerInfoUnpaired().then(function (ret) {
if(api.currentGame != 0) { // make sure host isn't already in a game
@ -96,6 +97,12 @@ function pairPushed() {
return;
}
api.refreshServerInfo().then(function (ret) {
if(api.paired) { // don't pair if you don't have to
snackbarLog('already paired with ' + target + '!');
return;
} else { // we're not already paired. pair now.
$('#pairButton')[0].innerHTML = 'Pairing...';
snackbarLog('Attempting pair to: ' + target);
var randomNumber = String("0000" + (Math.random()*10000|0)).slice(-4);
@ -132,6 +139,9 @@ function pairPushed() {
}
console.log("pairing attempt returned: " + ret3);
});
}
});
});
}