Wake on LAN support. Many fixes for Limelight Android 2.5.

This commit is contained in:
Cameron Gutman
2014-07-03 23:30:29 -07:00
parent a4dceb0b74
commit 894110ba08
5 changed files with 189 additions and 7 deletions
@@ -13,6 +13,7 @@ import java.net.URLConnection;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Stack;
import java.util.UUID;
import javax.crypto.SecretKey;
@@ -20,6 +21,8 @@ import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import com.limelight.nvstream.http.PairingManager.PairState;
public class NvHTTP {
private String uniqueId;
@@ -27,7 +30,7 @@ public class NvHTTP {
private LimelightCryptoProvider cryptoProvider;
public static final int PORT = 47984;
public static final int CONNECTION_TIMEOUT = 5000;
public static final int CONNECTION_TIMEOUT = 2000;
private final boolean verbose = false;
@@ -96,6 +99,35 @@ public class NvHTTP {
throw new GfeHttpResponseException(statusCode, xpp.getAttributeValue(XmlPullParser.NO_NAMESPACE, "status_message"));
}
}
public ComputerDetails getComputerDetails() throws MalformedURLException, IOException, XmlPullParserException {
ComputerDetails details = new ComputerDetails();
String serverInfo = openHttpConnectionToString(baseUrl + "/serverinfo?uniqueid=" + uniqueId);
details.name = getXmlString(serverInfo, "hostname");
details.uuid = UUID.fromString(getXmlString(serverInfo, "uniqueid"));
details.localIp = InetAddress.getByName(getXmlString(serverInfo, "LocalIP"));
details.remoteIp = InetAddress.getByName(getXmlString(serverInfo, "ExternalIP"));
details.macAddress = getXmlString(serverInfo, "mac");
try {
details.pairState = Integer.parseInt(getXmlString(serverInfo, "PairStatus")) == 1 ?
PairState.PAIRED : PairState.NOT_PAIRED;
} catch (NumberFormatException e) {
details.pairState = PairState.FAILED;
}
try {
details.runningGameId = Integer.parseInt(getXmlString(serverInfo, "currentgame"));
} catch (NumberFormatException e) {
details.runningGameId = 0;
}
// We could reach it so it's online
details.state = ComputerDetails.State.ONLINE;
return details;
}
private InputStream openHttpConnection(String url) throws IOException {
URLConnection conn = new URL(url).openConnection();
@@ -200,6 +232,10 @@ public class NvHTTP {
}
return appList;
}
public void unpair() throws IOException {
openHttpConnection(baseUrl + "/unpair?uniqueid=" + uniqueId);
}
public int launchApp(int appId, int width, int height, int refreshRate, SecretKey inputKey) throws IOException, XmlPullParserException {
InputStream in = openHttpConnection(baseUrl +