summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-04-20 09:08:58 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-04-20 09:08:58 (GMT)
commit19ea69686d0af6977fe02bc29a664d57195b8127 (patch)
treec0f9864d76c060681faa5702219818889d7ad5ee /src
parenta7556f33a88aa622460d1f05f8869b88cb23ca93 (diff)
downloadstroke-19ea69686d0af6977fe02bc29a664d57195b8127.zip
stroke-19ea69686d0af6977fe02bc29a664d57195b8127.tar.bz2
Also emit onDisconnected after a manual disconnect
Diffstat (limited to 'src')
-rw-r--r--src/com/isode/stroke/network/JavaConnection.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/com/isode/stroke/network/JavaConnection.java b/src/com/isode/stroke/network/JavaConnection.java
index e5369bf..07e702e 100644
--- a/src/com/isode/stroke/network/JavaConnection.java
+++ b/src/com/isode/stroke/network/JavaConnection.java
@@ -118,6 +118,7 @@ public class JavaConnection extends Connection implements EventOwner {
} catch (IOException ex) {
/* Do we need to return an error if we're already trying to close? */
}
+ handleDisconnected(null);
}
private void handleConnected(final boolean error) {
@@ -129,11 +130,14 @@ public class JavaConnection extends Connection implements EventOwner {
}
private void handleDisconnected(final Error error) {
- eventLoop_.postEvent(new Callback() {
- public void run() {
- onDisconnected.emit(error);
- }
- });
+ if (!disconnected_) {
+ disconnected_ = true;
+ eventLoop_.postEvent(new Callback() {
+ public void run() {
+ onDisconnected.emit(error);
+ }
+ });
+ }
}
private void handleDataRead(final ByteArray data) {
@@ -203,6 +207,7 @@ public class JavaConnection extends Connection implements EventOwner {
private final EventLoop eventLoop_;
private boolean disconnecting_ = false;
+ private boolean disconnected_ = false;
private SocketChannel socketChannel_;
private Worker worker_;