From 8688966ca6a02eb3819d94ddce5191ceab46e00b Mon Sep 17 00:00:00 2001 From: Matt Tucker Date: Tue, 21 Oct 2003 17:39:18 +0000 Subject: [PATCH] Keeps track of the number of packets written. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2153 b35dd754-fafc-0310-a699-88a17e54d16e --- source/org/jivesoftware/smack/PacketWriter.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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.