mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-22 04:22:45 +00:00
Fix PC duplication issue when multiple machines report the same remote IP address
This commit is contained in:
parent
5dcff91d27
commit
871b73c48d
@ -332,12 +332,22 @@ public class ComputerManagerService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ComputerDetails tryPollIp(InetAddress ipAddr) {
|
private ComputerDetails tryPollIp(ComputerDetails details, InetAddress ipAddr) {
|
||||||
try {
|
try {
|
||||||
NvHTTP http = new NvHTTP(ipAddr, idManager.getUniqueId(),
|
NvHTTP http = new NvHTTP(ipAddr, idManager.getUniqueId(),
|
||||||
null, PlatformBinding.getCryptoProvider(ComputerManagerService.this));
|
null, PlatformBinding.getCryptoProvider(ComputerManagerService.this));
|
||||||
|
|
||||||
return http.getComputerDetails();
|
ComputerDetails newDetails = http.getComputerDetails();
|
||||||
|
|
||||||
|
// Check if this is the PC we expected
|
||||||
|
if (details.uuid != null && newDetails.uuid != null &&
|
||||||
|
!details.uuid.equals(newDetails.uuid)) {
|
||||||
|
// We got the wrong PC!
|
||||||
|
LimeLog.info("Polling returned the wrong PC!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return newDetails;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -347,19 +357,19 @@ public class ComputerManagerService extends Service {
|
|||||||
ComputerDetails polledDetails;
|
ComputerDetails polledDetails;
|
||||||
|
|
||||||
if (localFirst) {
|
if (localFirst) {
|
||||||
polledDetails = tryPollIp(details.localIp);
|
polledDetails = tryPollIp(details, details.localIp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
polledDetails = tryPollIp(details.remoteIp);
|
polledDetails = tryPollIp(details, details.remoteIp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (polledDetails == null && !details.localIp.equals(details.remoteIp)) {
|
if (polledDetails == null && !details.localIp.equals(details.remoteIp)) {
|
||||||
// Failed, so let's try the fallback
|
// Failed, so let's try the fallback
|
||||||
if (!localFirst) {
|
if (!localFirst) {
|
||||||
polledDetails = tryPollIp(details.localIp);
|
polledDetails = tryPollIp(details, details.localIp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
polledDetails = tryPollIp(details.remoteIp);
|
polledDetails = tryPollIp(details, details.remoteIp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The fallback poll worked
|
// The fallback poll worked
|
||||||
@ -417,8 +427,8 @@ public class ComputerManagerService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (ComputerDetails computer : dbManager.getAllComputers()) {
|
for (ComputerDetails computer : dbManager.getAllComputers()) {
|
||||||
// Add this computer without a thread
|
// Add tuples for each computer
|
||||||
pollingTuples.add(new PollingTuple(computer, null));
|
addTuple(computer);
|
||||||
}
|
}
|
||||||
|
|
||||||
releaseLocalDatabaseReference();
|
releaseLocalDatabaseReference();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user