From 19ea69686d0af6977fe02bc29a664d57195b8127 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Fri, 20 Apr 2012 10:08:58 +0100 Subject: Also emit onDisconnected after a manual disconnect 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_; -- cgit v0.10.2-6-g49f6