sort Igtimi WebSocket URLs to the top that don't do wss:// nor port 443; Jetty can't do wss://

This commit is contained in:
Axel Uhl
2014-07-14 21:45:35 +02:00
parent 443c9167a3
commit 22d0d5a82d
@@ -7,6 +7,8 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -498,6 +500,15 @@ public class IgtimiConnectionFactoryImpl implements IgtimiConnectionFactory {
URI uri = new URI((String) serverUrl);
result.add(uri);
}
// sort those to the front that don't do port 443 nor wss://
Collections.sort(result, new Comparator<URI>() {
@Override
public int compare(URI o1, URI o2) {
int o1Score = (o1.toString().contains("443") ? 1 : 0) + (o1.toString().contains("wss") ? 1 : 0);
int o2Score = (o2.toString().contains("443") ? 1 : 0) + (o2.toString().contains("wss") ? 1 : 0);
return o1Score - o2Score;
}
});
return result;
}