Commit d4868815 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Fixed parsing problem that was "disappearing" white spaces and \n from parsed content. JM-500

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3332 b35dd754-fafc-0310-a699-88a17e54d16e
parent 12441e34
......@@ -264,12 +264,17 @@ public class XMPPPacketReader {
/**
* Returns the last time a full Document was read or a heartbeat was received. Hearbeats
* are represented as whitespaces received while a Document is not being parsed.
* are represented as whitespaces or \n received while a Document is not being parsed.
*
* @return the time in milliseconds when the last document or heartbeat was received.
*/
public long getLastActive() {
return lastActive;
long lastHeartbeat = 0;
try {
lastHeartbeat = getXPPParser().getLastHeartbeat();
}
catch (XmlPullParserException e) {}
return lastActive > lastHeartbeat ? lastActive : lastHeartbeat;
}
// Implementation methods
......@@ -393,11 +398,6 @@ public class XMPPPacketReader {
}
break;
}
case XmlPullParser.IGNORABLE_WHITESPACE: {
//System.out.println("Heartbeat was detected");
// Update the last time a heartbeat was received
lastActive = System.currentTimeMillis();
}
default:
{
;
......
......@@ -25,6 +25,13 @@ import java.io.Reader;
*/
public class MXParser extends org.xmlpull.mxp1.MXParser {
/**
* Last time a heartbeat was received. Hearbeats are represented as whitespaces
* or \n characters received when an XmlPullParser.END_TAG was parsed. Note that we
* can falsely detect heartbeats when parsing XHTML content but that is fine.
*/
private long lastHeartbeat = 0;
protected int nextImpl()
throws XmlPullParserException, IOException
{
......@@ -259,9 +266,9 @@ public class MXParser extends org.xmlpull.mxp1.MXParser {
// check that ]]> does not show in
if (eventType == XmlPullParser.END_TAG && (ch == ' ' || ch == '\n')) {
// ** ADDED CODE (INCLUDING IF STATEMENT)
return IGNORABLE_WHITESPACE;
lastHeartbeat = System.currentTimeMillis();;
}
else if(ch == ']') {
if(ch == ']') {
if(seenBracket) {
seenBracketBracket = true;
} else {
......@@ -325,6 +332,17 @@ public class MXParser extends org.xmlpull.mxp1.MXParser {
}
}
/**
* Returns the last time a heartbeat was received. Hearbeats are represented as whitespaces
* or \n characters received when an XmlPullParser.END_TAG was parsed. Note that we
* can falsely detect heartbeats when parsing XHTML content but that is fine.
*
* @return the time in milliseconds when a heartbeat was received.
*/
public long getLastHeartbeat() {
return lastHeartbeat;
}
public void resetInput() {
Reader oldReader = reader;
String oldEncoding = inputEncoding;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment