diff options
author | Kevin Smith <git@kismith.co.uk> | 2012-02-23 16:37:07 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2012-02-23 16:37:07 (GMT) |
commit | c80110013f16d8aa4e6e9801e01ce9ccab1e6592 (patch) | |
tree | 7d02d379a82dda81fb2e3524b1631e7763baaf32 /src | |
parent | f5e722a7f28f3407600e023700739ff3b9cc83c2 (diff) | |
download | stroke-c80110013f16d8aa4e6e9801e01ce9ccab1e6592.zip stroke-c80110013f16d8aa4e6e9801e01ce9ccab1e6592.tar.bz2 |
Allow non-standard ports on internal interface method
Diffstat (limited to 'src')
-rw-r--r-- | src/com/isode/stroke/client/CoreClient.java | 11 | ||||
-rw-r--r-- | src/com/isode/stroke/network/Connector.java | 10 |
2 files changed, 13 insertions, 8 deletions
diff --git a/src/com/isode/stroke/client/CoreClient.java b/src/com/isode/stroke/client/CoreClient.java index 828906c..c01d57a 100644 --- a/src/com/isode/stroke/client/CoreClient.java +++ b/src/com/isode/stroke/client/CoreClient.java @@ -128,20 +128,23 @@ public class CoreClient { */ public void connect(ClientOptions o) { options = o; - connect(jid_.getDomain()); + connect(jid_.getDomain(), 5222); } /** - * Connect to the specified host, overriding the standard lookup rules. + * Connect to the specified host, overriding the standard lookup rules for the JID. + * + * Internal method, do not use. * * @param host Host to connect to, non-null. + * @param port Default port to use if SRV fails. */ - public void connect(String host) { + public void connect(String host, int port) { options = new ClientOptions(); disconnectRequested_ = false; assert (connector_ == null); /* FIXME: Port Proxies */ - connector_ = Connector.create(host, networkFactories.getDomainNameResolver(), networkFactories.getConnectionFactory(), networkFactories.getTimerFactory()); + connector_ = Connector.create(host, networkFactories.getDomainNameResolver(), networkFactories.getConnectionFactory(), networkFactories.getTimerFactory(), port); connectorConnectFinishedConnection_ = connector_.onConnectFinished.connect(new Slot1<Connection>() { public void call(Connection p1) { handleConnectorFinished(p1); diff --git a/src/com/isode/stroke/network/Connector.java b/src/com/isode/stroke/network/Connector.java index 01fd114..fba0b95 100644 --- a/src/com/isode/stroke/network/Connector.java +++ b/src/com/isode/stroke/network/Connector.java @@ -19,8 +19,8 @@ import java.util.Collection; public class Connector { - public static Connector create(String hostname, DomainNameResolver resolver, ConnectionFactory connectionFactory, TimerFactory timerFactory) { - return new Connector(hostname, resolver, connectionFactory, timerFactory); + public static Connector create(String hostname, DomainNameResolver resolver, ConnectionFactory connectionFactory, TimerFactory timerFactory, int defaultPort) { + return new Connector(hostname, resolver, connectionFactory, timerFactory, defaultPort); } public void setTimeoutMilliseconds(int milliseconds) { @@ -56,11 +56,12 @@ public class Connector { public final Signal1<Connection> onConnectFinished = new Signal1<Connection>(); - private Connector(String hostname, DomainNameResolver resolver, ConnectionFactory connectionFactory, TimerFactory timerFactory) { + private Connector(String hostname, DomainNameResolver resolver, ConnectionFactory connectionFactory, TimerFactory timerFactory, int defaultPort) { this.hostname = hostname; this.resolver = resolver; this.connectionFactory = connectionFactory; this.timerFactory = timerFactory; + this.defaultPort = defaultPort; } private void handleServiceQueryResult(Collection<Result> result) { @@ -128,7 +129,7 @@ public class Connector { HostAddress address = addressQueryResults.get(0); addressQueryResults.remove(0); - int port = 5222; + int port = defaultPort; if (!serviceQueryResults.isEmpty()) { port = serviceQueryResults.get(0).port; } @@ -215,4 +216,5 @@ public class Connector { private boolean queriedAllServices = true; private Connection currentConnection; private SignalConnection currentConnectionConnectFinishedConnection; + private final int defaultPort; } |