mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-25 06:58:39 +00:00
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:
+11
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user