Better connection closing notification logic.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1987 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2003-07-16 02:49:43 +00:00 committed by mtucker
parent 40624c9c0b
commit e256a1d149
1 changed files with 9 additions and 8 deletions

View File

@ -201,6 +201,13 @@ class PacketReader {
*/ */
public void shutdown() { public void shutdown() {
done = true; done = true;
// Notify connection listeners of the connection closing.
synchronized (connectionListeners) {
for (Iterator i=connectionListeners.iterator(); i.hasNext(); ) {
ConnectionListener listener = (ConnectionListener)i.next();
listener.connectionClosed();
}
}
} }
/** /**
@ -271,18 +278,12 @@ class PacketReader {
} }
else if (eventType == XmlPullParser.END_TAG) { else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("stream")) { if (parser.getName().equals("stream")) {
// Close the connection.
connection.close(); connection.close();
done = true;
} }
} }
eventType = parser.next(); eventType = parser.next();
} while (eventType != XmlPullParser.END_DOCUMENT && !done); } while (!done && eventType != XmlPullParser.END_DOCUMENT);
synchronized (connectionListeners) {
for (Iterator i=connectionListeners.iterator(); i.hasNext(); ) {
ConnectionListener listener = (ConnectionListener)i.next();
listener.connectionClosed();
}
}
} }
catch (Exception e) { catch (Exception e) {
if (!done) { if (!done) {