Function name change, additional comments, code cleanup for remote disc streaming

This commit is contained in:
Fireball Wayne committed 2017-03-11 00:46:50 -05:00
1 parent ce7a93e24c
commit ed046079a5
5 files changed
+55 -50

No files matched your search

+49 -45
View File
@@ -198,52 +198,56 @@ static bool FindServer(std::string &resultHost, int &resultPort) {
return true;
}
if(!g_Config.bRemoteISOManual) {
// Start by requesting a list of recent local ips for this network.
if (http.Resolve(REPORT_HOSTNAME, REPORT_PORT)) {
if (http.Connect()) {
code = http.GET("/match/list", &result);
http.Disconnect();
}
}
//don't scan if in manual mode
if (g_Config.bRemoteISOManual) {
return false;
}
if (code != 200 || scanCancelled) {
return false;
}
std::string json;
result.TakeAll(&json);
JsonReader reader(json.c_str(), json.size());
if (!reader.ok()) {
return false;
}
const json_value *entries = reader.root();
if (!entries) {
return false;
}
std::vector<std::string> servers;
const json_value *entry = entries->first_child;
while (entry) {
const char *host = entry->getString("ip", "");
int port = entry->getInt("p", 0);
char url[1024] = {};
snprintf(url, sizeof(url), "http://%s:%d", host, port);
servers.push_back(url);
if (http.Resolve(host, port) && http.Connect()) {
http.Disconnect();
resultHost = host;
resultPort = port;
return true;
}
entry = entry->next_sibling;
// Start by requesting a list of recent local ips for this network.
if (http.Resolve(REPORT_HOSTNAME, REPORT_PORT)) {
if (http.Connect()) {
code = http.GET("/match/list", &result);
http.Disconnect();
}
}
if (code != 200 || scanCancelled) {
return false;
}
std::string json;
result.TakeAll(&json);
JsonReader reader(json.c_str(), json.size());
if (!reader.ok()) {
return false;
}
const json_value *entries = reader.root();
if (!entries) {
return false;
}
std::vector<std::string> servers;
const json_value *entry = entries->first_child;
while (entry) {
const char *host = entry->getString("ip", "");
int port = entry->getInt("p", 0);
char url[1024] = {};
snprintf(url, sizeof(url), "http://%s:%d", host, port);
servers.push_back(url);
if (http.Resolve(host, port) && http.Connect()) {
http.Disconnect();
resultHost = host;
resultPort = port;
return true;
}
entry = entry->next_sibling;
}
// None of the local IPs were reachable.
return false;
}
@@ -275,7 +279,7 @@ static bool LoadGameList(const std::string &host, int port, std::vector<std::str
std::vector<std::string> items;
result.TakeAll(&listing);
if (startsWith(responseHeaders[0],"Server: SuperDuperServer")) {
if (startsWith(responseHeaders[0],"Server: PPSSPPServer") || startsWith(responseHeaders[0], "Server: SuperDuperServer")) {
//ppsspp server
SplitString(listing, '\n', items);
for (const std::string &item : items) {
@@ -289,7 +293,7 @@ static bool LoadGameList(const std::string &host, int port, std::vector<std::str
}
} else {
//other webserver
FindQuotedStrings(listing, items);
GetQuotedStrings(listing, items);
for (const std::string &item : items) {
if (!endsWithNoCase(item, ".cso") && !endsWithNoCase(item, ".iso") && !endsWithNoCase(item, ".pbp")) {