diff options
author | Nick Hudson <nick.hudson@isode.com> | 2014-08-29 10:26:39 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2014-10-24 12:42:19 (GMT) |
commit | dabadc693220858ecb34af7e8df5f4e0b32461fc (patch) | |
tree | d95f0bbdbf8bf81621f5f504b596428fda0ae481 /src/com | |
parent | e82c5e8cae00d7f9d4b0c42e9e8e38f22c072c6d (diff) | |
download | stroke-dabadc693220858ecb34af7e8df5f4e0b32461fc.zip stroke-dabadc693220858ecb34af7e8df5f4e0b32461fc.tar.bz2 |
Fix JavaConnection to emit onDataWritten when it writes data to the socket
The java code was never emitting the onDataWritten signal, although
the corresponding C++ code in Swiften does do this.
This change causes the signal to be emitted whenever a data is
successfully written to the socket.
Test-information:
Tested using an application which was registering for the signal;
previously it never saw "onDataWritten"; now it does.
Tested using an application which doesn't register for the signal; it
works as before.
Change-Id: I1399af0721ef8226c0c4d2420bbe23f53ad3494f
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/isode/stroke/network/JavaConnection.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/com/isode/stroke/network/JavaConnection.java b/src/com/isode/stroke/network/JavaConnection.java index 3f768dc..807d971 100644 --- a/src/com/isode/stroke/network/JavaConnection.java +++ b/src/com/isode/stroke/network/JavaConnection.java @@ -177,13 +177,21 @@ public class JavaConnection extends Connection implements EventOwner { */ boolean finishedWriting = false; int bytesWritten = socketChannel_.write(byteBuffer); + final boolean somethingWasWritten = (bytesWritten != 0); + if (somethingWasWritten) { + eventLoop_.postEvent(new Callback() { + public void run() { + onDataWritten.emit(); + } + }); + } finishedWriting = (byteBuffer.remaining() == 0); if (finishedWriting) { writeBuffer_.remove(0); return; } /* Was anything written at all? */ - if (bytesWritten == 0) { + if (!somethingWasWritten) { /* Leave the buffer in the array so that it'll get tried * again later */ |