diff options
author | Matthew Johnson <mjj29@hecate.matthew.ath.cx> | 2008-01-10 14:23:34 +0000 |
---|---|---|
committer | Matthew Johnson <mjj29@hecate.matthew.ath.cx> | 2008-01-10 14:23:34 +0000 |
commit | 55249d9c6c2648d182707ff692703284e209b9d1 (patch) | |
tree | 2bf7e20a4510d897c4b56daff4f455ea8da95050 | |
parent | 4f69644ac42412d4325b539970d0c282d490b135 (diff) |
Write multiple byte[] at once
-rw-r--r-- | INSTALL | 2 | ||||
-rw-r--r-- | changelog | 2 | ||||
-rw-r--r-- | org/freedesktop/dbus/MessageWriter.java | 21 |
3 files changed, 18 insertions, 7 deletions
@@ -8,7 +8,7 @@ To compile and install the library you will need: A Java 1.5-compliant VM and Compiler (at time of writing only the Sun VM and Compiler is known to work). - The unix socket, debug and hexdump libraries from http://www.matthew.ath.cx/projects/java/ + The unix socket, debug and hexdump libraries from http://www.matthew.ath.cx/projects/java/ (version 0.6 or later) GNU gettext To build and install the documentation you will also need: @@ -13,6 +13,8 @@ Version 2.4: * Throw a nicer error when signals are not declared as part of an interface. * .viewerclasses needs to depend on .binclasses + * Use libunixsocket-java support for writing multiple byte arrays at + once to write message vectors Version 2.3.2: diff --git a/org/freedesktop/dbus/MessageWriter.java b/org/freedesktop/dbus/MessageWriter.java index ad7e2af..86b54de 100644 --- a/org/freedesktop/dbus/MessageWriter.java +++ b/org/freedesktop/dbus/MessageWriter.java @@ -15,6 +15,7 @@ import java.io.OutputStream; import java.io.IOException; import cx.ath.matthew.debug.Debug; +import cx.ath.matthew.unix.USOutputStream; import cx.ath.matthew.utils.Hexdump; public class MessageWriter @@ -34,12 +35,20 @@ public class MessageWriter if (Debug.debug) Debug.print(Debug.WARN, "Message "+m+" wire-data was null!"); return; } - for (byte[] buf: m.getWireData()) { - if (Debug.debug) - Debug.print(Debug.VERBOSE, "("+buf+"):"+ (null==buf? "": Hexdump.format(buf))); - if (null == buf) break; - out.write(buf); - } + if (out instanceof USOutputStream) { + if (Debug.debug) { + Debug.print(Debug.DEBUG, "Writing all "+m.getWireData().length+" buffers simultaneously to Unix Socket"); + for (byte[] buf: m.getWireData()) + Debug.print(Debug.VERBOSE, "("+buf+"):"+ (null==buf? "": Hexdump.format(buf))); + } + ((USOutputStream) out).write(m.getWireData()); + } else + for (byte[] buf: m.getWireData()) { + if (Debug.debug) + Debug.print(Debug.VERBOSE, "("+buf+"):"+ (null==buf? "": Hexdump.format(buf))); + if (null == buf) break; + out.write(buf); + } out.flush(); } public void close() throws IOException |