Commit 71bffb93 authored by Drahomír Karchňák's avatar Drahomír Karchňák

Registration Resource retuns user_server_selection field, which indicades...

Registration Resource retuns user_server_selection field, which indicades whether or not we got user selected server details.
parent 3c58937f
......@@ -478,10 +478,11 @@ public class InformationCollector
}
private static void addClientFeatures(JSONObject object, Context ctx) throws JSONException {
//TODO - Server selection is active on debug builds
object.put("user_server_selection", true);
Server server;
if((server = ConfigHelper.getUserSelectedServer(ctx)) != null) {
object.put("user_server_selection", true);
object.put("prefer_server", server.getUuid());
}
}
......
......@@ -15,6 +15,8 @@
******************************************************************************/
package at.alladin.rmbt.client.helper;
import android.util.Log;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
......@@ -84,9 +86,6 @@ public class ControlServerConnection
public List<TaskDesc> v2TaskDesc;
private long startTimeNs = 0;
/**
* @param args
*/
public ControlServerConnection()
{
......@@ -274,7 +273,11 @@ public class ControlServerConnection
testUuid = response.getString("test_uuid");
testTime = System.currentTimeMillis() + 1000 * response.getLong("test_wait");
if(response.optBoolean("user_server_selection", false)) {
System.out.println(getClass().getSimpleName() + ": User server selection is active. We received intended server.");
}
testHost = response.getString("test_server_address");
testPort = response.getInt("test_server_port");
testEncryption = response.getBoolean("test_server_encryption");
......
......@@ -259,14 +259,18 @@ public class RegistrationResource extends ServerResource
final Boolean userServerSelection = request.optBoolean("user_server_selection");
boolean serverSelectionResult = false;
if(userServerSelection) {
final String preferServer = request.optString("prefer_server", null);
if(!Strings.isNullOrEmpty(preferServer)) {
serverSelectionResult = true;
server = getPreferredServer(preferServer, testServerEncryption, ipv6);
}
}
if(server == null) {
serverSelectionResult = false;
server = getNearestServer(errorList, geolat, geolong, geotime, clientIpString,
asCountry, geoIpCountry, serverType, testServerEncryption, ipv6);
}
......@@ -283,7 +287,8 @@ public class RegistrationResource extends ServerResource
}
else
timeWithZone = Helperfunctions.getTimeWithTimeZone(timeZoneId);
answer.put("user_server_selection", serverSelectionResult);
answer.put("test_server_address", server.address);
answer.put("test_server_port", server.port);
answer.put("test_server_name", server.name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment