mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-19 11:03:01 +00:00
Rework active address to not be based on reachability and allow for a manual address
This commit is contained in:
parent
c9cf485025
commit
514e0ca2c9
@ -7,25 +7,25 @@ public class ComputerDetails {
|
|||||||
public enum State {
|
public enum State {
|
||||||
ONLINE, OFFLINE, UNKNOWN
|
ONLINE, OFFLINE, UNKNOWN
|
||||||
}
|
}
|
||||||
public enum Reachability {
|
|
||||||
LOCAL, REMOTE, OFFLINE, UNKNOWN
|
// Persistent attributes
|
||||||
}
|
|
||||||
|
|
||||||
public State state;
|
|
||||||
public Reachability reachability;
|
|
||||||
public String name;
|
|
||||||
public UUID uuid;
|
public UUID uuid;
|
||||||
|
public String name;
|
||||||
public String localAddress;
|
public String localAddress;
|
||||||
public String remoteAddress;
|
public String remoteAddress;
|
||||||
public PairingManager.PairState pairState;
|
public String manualAddress;
|
||||||
public String macAddress;
|
public String macAddress;
|
||||||
|
|
||||||
|
// Transient attributes
|
||||||
|
public State state;
|
||||||
|
public String activeAddress;
|
||||||
|
public PairingManager.PairState pairState;
|
||||||
public int runningGameId;
|
public int runningGameId;
|
||||||
public String rawAppList;
|
public String rawAppList;
|
||||||
|
|
||||||
public ComputerDetails() {
|
public ComputerDetails() {
|
||||||
// Use defaults
|
// Use defaults
|
||||||
state = State.UNKNOWN;
|
state = State.UNKNOWN;
|
||||||
reachability = Reachability.UNKNOWN;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComputerDetails(ComputerDetails details) {
|
public ComputerDetails(ComputerDetails details) {
|
||||||
@ -35,12 +35,23 @@ public class ComputerDetails {
|
|||||||
|
|
||||||
public void update(ComputerDetails details) {
|
public void update(ComputerDetails details) {
|
||||||
this.state = details.state;
|
this.state = details.state;
|
||||||
this.reachability = details.reachability;
|
|
||||||
this.name = details.name;
|
this.name = details.name;
|
||||||
this.uuid = details.uuid;
|
this.uuid = details.uuid;
|
||||||
this.localAddress = details.localAddress;
|
if (details.activeAddress != null) {
|
||||||
this.remoteAddress = details.remoteAddress;
|
this.activeAddress = details.activeAddress;
|
||||||
this.macAddress = details.macAddress;
|
}
|
||||||
|
if (details.localAddress != null) {
|
||||||
|
this.localAddress = details.localAddress;
|
||||||
|
}
|
||||||
|
if (details.remoteAddress != null) {
|
||||||
|
this.remoteAddress = details.remoteAddress;
|
||||||
|
}
|
||||||
|
if (details.manualAddress != null) {
|
||||||
|
this.manualAddress = details.manualAddress;
|
||||||
|
}
|
||||||
|
if (details.macAddress != null && !details.macAddress.equals("00:00:00:00:00:00")) {
|
||||||
|
this.macAddress = details.macAddress;
|
||||||
|
}
|
||||||
this.pairState = details.pairState;
|
this.pairState = details.pairState;
|
||||||
this.runningGameId = details.runningGameId;
|
this.runningGameId = details.runningGameId;
|
||||||
this.rawAppList = details.rawAppList;
|
this.rawAppList = details.rawAppList;
|
||||||
@ -50,11 +61,12 @@ public class ComputerDetails {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder str = new StringBuilder();
|
StringBuilder str = new StringBuilder();
|
||||||
str.append("State: ").append(state).append("\n");
|
str.append("State: ").append(state).append("\n");
|
||||||
str.append("Reachability: ").append(reachability).append("\n");
|
str.append("Active Address: ").append(activeAddress).append("\n");
|
||||||
str.append("Name: ").append(name).append("\n");
|
str.append("Name: ").append(name).append("\n");
|
||||||
str.append("UUID: ").append(uuid).append("\n");
|
str.append("UUID: ").append(uuid).append("\n");
|
||||||
str.append("Local IP: ").append(localAddress).append("\n");
|
str.append("Local Address: ").append(localAddress).append("\n");
|
||||||
str.append("Remote IP: ").append(remoteAddress).append("\n");
|
str.append("Remote Address: ").append(remoteAddress).append("\n");
|
||||||
|
str.append("Manual Address: ").append(manualAddress).append("\n");
|
||||||
str.append("MAC Address: ").append(macAddress).append("\n");
|
str.append("MAC Address: ").append(macAddress).append("\n");
|
||||||
str.append("Pair State: ").append(pairState).append("\n");
|
str.append("Pair State: ").append(pairState).append("\n");
|
||||||
str.append("Running Game ID: ").append(runningGameId).append("\n");
|
str.append("Running Game ID: ").append(runningGameId).append("\n");
|
||||||
|
@ -215,18 +215,10 @@ public class NvHTTP {
|
|||||||
|
|
||||||
details.uuid = UUID.fromString(getXmlString(serverInfo, "uniqueid"));
|
details.uuid = UUID.fromString(getXmlString(serverInfo, "uniqueid"));
|
||||||
details.macAddress = getXmlString(serverInfo, "mac");
|
details.macAddress = getXmlString(serverInfo, "mac");
|
||||||
|
|
||||||
// If there's no LocalIP field, use the address we hit the server on
|
|
||||||
details.localAddress = getXmlString(serverInfo, "LocalIP");
|
details.localAddress = getXmlString(serverInfo, "LocalIP");
|
||||||
if (details.localAddress == null) {
|
|
||||||
details.localAddress = address;
|
// This may be null, but that's okay
|
||||||
}
|
|
||||||
|
|
||||||
// If there's no ExternalIP field, use the address we hit the server on
|
|
||||||
details.remoteAddress = getXmlString(serverInfo, "ExternalIP");
|
details.remoteAddress = getXmlString(serverInfo, "ExternalIP");
|
||||||
if (details.remoteAddress == null) {
|
|
||||||
details.remoteAddress = address;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
details.pairState = Integer.parseInt(getXmlString(serverInfo, "PairStatus")) == 1 ?
|
details.pairState = Integer.parseInt(getXmlString(serverInfo, "PairStatus")) == 1 ?
|
||||||
|
@ -26,8 +26,12 @@ public class WakeOnLanSender {
|
|||||||
// The broadcast address is required to avoid stale ARP cache entries
|
// The broadcast address is required to avoid stale ARP cache entries
|
||||||
// making the sleeping machine unreachable.
|
// making the sleeping machine unreachable.
|
||||||
for (String unresolvedAddress : new String[] {
|
for (String unresolvedAddress : new String[] {
|
||||||
computer.localAddress, computer.remoteAddress, "255.255.255.255"
|
computer.localAddress, computer.remoteAddress, computer.manualAddress, "255.255.255.255"
|
||||||
}) {
|
}) {
|
||||||
|
if (unresolvedAddress == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (InetAddress resolvedAddress : InetAddress.getAllByName(unresolvedAddress)) {
|
for (InetAddress resolvedAddress : InetAddress.getAllByName(unresolvedAddress)) {
|
||||||
// Try all the ports for each resolved address
|
// Try all the ports for each resolved address
|
||||||
|
Loading…
x
Reference in New Issue
Block a user