Refactoring work.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@3179 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2005-12-08 21:10:41 +00:00 committed by gato
parent 647d6323ca
commit 38f7e5bba7
1 changed files with 18 additions and 13 deletions

View File

@ -79,14 +79,7 @@ class PacketReader {
listenerThread.setName("Smack Listener Processor"); listenerThread.setName("Smack Listener Processor");
listenerThread.setDaemon(true); listenerThread.setDaemon(true);
try { resetParser();
parser = new MXParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
parser.setInput(connection.reader);
}
catch (XmlPullParserException xppe) {
xppe.printStackTrace();
}
} }
/** /**
@ -224,8 +217,15 @@ class PacketReader {
* when the plain connection has been secured or when a new opening stream element is going * when the plain connection has been secured or when a new opening stream element is going
* to be sent by the server. * to be sent by the server.
*/ */
private void resetParser() throws XmlPullParserException { private void resetParser() {
parser.setInput(connection.reader); try {
parser = new MXParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
parser.setInput(connection.reader);
}
catch (XmlPullParserException xppe) {
xppe.printStackTrace();
}
} }
/** /**
@ -335,12 +335,17 @@ class PacketReader {
connection.getSASLAuthentication().challengeReceived(parser.nextText()); connection.getSASLAuthentication().challengeReceived(parser.nextText());
} }
else if (parser.getName().equals("success")) { else if (parser.getName().equals("success")) {
// The SASL authentication with the server was successful. The next step // We now need to bind a resource for the connection
// will be to bind the resource // Open a new stream and wait for the response
connection.getSASLAuthentication().authenticated(); connection.packetWriter.openStream();
// Reset the state of the parser since a new stream element is going // Reset the state of the parser since a new stream element is going
// to be sent by the server // to be sent by the server
resetParser(); resetParser();
// The SASL authentication with the server was successful. The next step
// will be to bind the resource
connection.getSASLAuthentication().authenticated();
} }
} }
else if (eventType == XmlPullParser.END_TAG) { else if (eventType == XmlPullParser.END_TAG) {