aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/xmpp/router
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/xmpp/router')
-rw-r--r--juick-server/src/main/java/com/juick/server/xmpp/router/StreamError.java27
1 files changed, 20 insertions, 7 deletions
diff --git a/juick-server/src/main/java/com/juick/server/xmpp/router/StreamError.java b/juick-server/src/main/java/com/juick/server/xmpp/router/StreamError.java
index 7eacfc94..f731f039 100644
--- a/juick-server/src/main/java/com/juick/server/xmpp/router/StreamError.java
+++ b/juick-server/src/main/java/com/juick/server/xmpp/router/StreamError.java
@@ -12,6 +12,7 @@ import java.io.IOException;
public class StreamError {
private String condition;
+ private String text;
public StreamError() {}
@@ -21,13 +22,21 @@ public class StreamError {
public static StreamError parse(XmlPullParser parser) throws IOException, XmlPullParserException {
StreamError streamError = new StreamError();
- while (parser.next() == XmlPullParser.START_TAG) {
- final String tag = parser.getName();
- final String xmlns = parser.getNamespace();
- if (xmlns.equals(StreamNamespaces.NS_XMPP_STREAMS)) {
- streamError.condition = tag;
- } else {
- XmlUtils.skip(parser);
+ final int initial = parser.getDepth();
+ while (true) {
+ int eventType = parser.next();
+ if (eventType == XmlPullParser.START_TAG && parser.getDepth() == initial + 1) {
+ final String tag = parser.getName();
+ final String xmlns = parser.getNamespace();
+ if (tag.equals("text") && xmlns.equals(StreamNamespaces.NS_XMPP_STREAMS)) {
+ streamError.text = XmlUtils.getTagText(parser);
+ } else if (xmlns.equals(StreamNamespaces.NS_XMPP_STREAMS)) {
+ streamError.condition = tag;
+ } else {
+ XmlUtils.skip(parser);
+ }
+ } else if (eventType == XmlPullParser.END_TAG && parser.getDepth() == initial) {
+ break;
}
}
return streamError;
@@ -41,4 +50,8 @@ public class StreamError {
public String toString() {
return String.format("<stream:error><%s xmlns='%s'/></stream:error>", condition, StreamNamespaces.NS_XMPP_STREAMS);
}
+
+ public String getText() {
+ return text;
+ }
}