diff --git a/source/org/jivesoftware/smack/PacketWriter.java b/source/org/jivesoftware/smack/PacketWriter.java index abc00beea..0bec87aa9 100644 --- a/source/org/jivesoftware/smack/PacketWriter.java +++ b/source/org/jivesoftware/smack/PacketWriter.java @@ -69,6 +69,7 @@ class PacketWriter { private XMPPConnection connection; private LinkedList queue; private boolean done = false; + private int packetsWritten = 0; /** * Creates a new packet writer with the specified connection. @@ -103,6 +104,15 @@ class PacketWriter { } } + /** + * Returns the number of packets written through this packet writer. + * + * @return the number of packets written. + */ + public int getPacketsWritten() { + return packetsWritten; + } + /** * Starts the packet writer thread and opens a connection to the server. The * packet writer will continue writing packets until {@link #shutdown} or an @@ -152,6 +162,8 @@ class PacketWriter { while (!done) { Packet packet = nextPacket(); writer.write(packet.toXML()); + // Increment the count of packets written. + packetsWritten++; writer.flush(); } // Close the stream.