summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/isode/stroke/network/Connector.java9
-rw-r--r--src/com/isode/stroke/network/ProxiedConnection.java10
2 files changed, 16 insertions, 3 deletions
diff --git a/src/com/isode/stroke/network/Connector.java b/src/com/isode/stroke/network/Connector.java
index 6033a89..2823679 100644
--- a/src/com/isode/stroke/network/Connector.java
+++ b/src/com/isode/stroke/network/Connector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2014, Isode Limited, London, England.
+ * Copyright (c) 2010-2016, Isode Limited, London, England.
* All rights reserved.
*/
/*
@@ -62,6 +62,13 @@ public class Connector {
}
public void stop() {
+ if (currentConnectionConnectFinishedConnection != null) {
+ currentConnectionConnectFinishedConnection.disconnect();
+ currentConnectionConnectFinishedConnection = null;
+ }
+ if (currentConnection != null) {
+ currentConnection.disconnect();
+ }
finish(null);
}
diff --git a/src/com/isode/stroke/network/ProxiedConnection.java b/src/com/isode/stroke/network/ProxiedConnection.java
index 5eac083..69b4b90 100644
--- a/src/com/isode/stroke/network/ProxiedConnection.java
+++ b/src/com/isode/stroke/network/ProxiedConnection.java
@@ -11,6 +11,8 @@
package com.isode.stroke.network;
+import java.util.logging.Logger;
+
import com.isode.stroke.signals.SignalConnection;
import com.isode.stroke.signals.Slot2;
import com.isode.stroke.signals.Slot1;
@@ -30,6 +32,7 @@ public abstract class ProxiedConnection extends Connection {
private SignalConnection onDataReadConnection_;
private SignalConnection onDisconnectedConnection_;
private SignalConnection onConnectFinishedConnection;
+ private Logger logger_ = Logger.getLogger(this.getClass().getName());
public ProxiedConnection(DomainNameResolver resolver, ConnectionFactory connectionFactory, TimerFactory timerFactory, final String proxyHost, int proxyPort) {
this.resolver_ = resolver;
@@ -49,7 +52,7 @@ public abstract class ProxiedConnection extends Connection {
onDisconnectedConnection_.disconnect();
}
if (connected_) {
- System.err.println("Warning: Connection was still established.");
+ logger_.warning("Warning: Connection was still established.");
}
}
finally {
@@ -76,8 +79,11 @@ public abstract class ProxiedConnection extends Connection {
}
public void disconnect() {
+ cancelConnector();
connected_ = false;
- connection_.disconnect();
+ if (connection_ != null) {
+ connection_.disconnect();
+ }
}
public void write(final SafeByteArray data) {