1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-23 20:42:06 +01:00

Add methods to enable/disable proxy types

This commit is contained in:
vanitasvitae 2017-06-30 15:19:36 +02:00
parent 59a600a0b6
commit dec275aa4d
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 29 additions and 8 deletions

View file

@ -55,6 +55,9 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
private List<Bytestream.StreamHost> localStreamHosts = null;
private List<Bytestream.StreamHost> availableStreamHosts = null;
private static boolean useLocalCandidates = true;
private static boolean useExternalCandidates = true;
private JingleS5BTransportManager(XMPPConnection connection) {
super(connection);
JingleContentProviderManager.addJingleContentTransportProvider(getNamespace(), new JingleS5BTransportProvider());
@ -213,4 +216,19 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
return jingle;
}
public static void setUseLocalCandidates(boolean localCandidates) {
JingleS5BTransportManager.useLocalCandidates = localCandidates;
}
public static void setUseExternalCandidates(boolean externalCandidates) {
JingleS5BTransportManager.useExternalCandidates = externalCandidates;
}
public static boolean isUseLocalCandidates() {
return useLocalCandidates;
}
public static boolean isUseExternalCandidates() {
return useExternalCandidates;
}
}

View file

@ -78,16 +78,19 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
Socks5Utils.createDigest(sid, jingleSession.getLocal(), jingleSession.getRemote()));
//Local host
if (JingleS5BTransportManager.isUseLocalCandidates()) {
for (Bytestream.StreamHost host : transportManager().getLocalStreamHosts()) {
jb.addTransportCandidate(new JingleS5BTransportCandidate(host, 100, JingleS5BTransportCandidate.Type.direct));
}
}
List<Bytestream.StreamHost> remoteHosts;
List<Bytestream.StreamHost> remoteHosts = Collections.emptyList();
if (JingleS5BTransportManager.isUseExternalCandidates()) {
try {
remoteHosts = transportManager().getAvailableStreamHosts();
} catch (InterruptedException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | SmackException.NoResponseException e) {
LOGGER.log(Level.WARNING, "Could not determine available StreamHosts.", e);
remoteHosts = Collections.emptyList();
}
}
for (Bytestream.StreamHost host : remoteHosts) {