diff options
author | 2018-04-02 13:39:13 +0300 | |
---|---|---|
committer | 2018-04-02 13:39:13 +0300 | |
commit | cb2d7e63fc9af26b06c2f02c98940aafecd87292 (patch) | |
tree | 98ef7c6ab6861032ecf22b010b3b5df9ef03b6a7 /juick-server/src/main/java/com/juick/server/xmpp/router/StreamError.java | |
parent | 84d960a1d82a5619c65ab59a00e86644f53200a3 (diff) |
xmpp: test router
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/xmpp/router/StreamError.java')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/xmpp/router/StreamError.java | 44 |
1 files changed, 44 insertions, 0 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 new file mode 100644 index 00000000..7eacfc94 --- /dev/null +++ b/juick-server/src/main/java/com/juick/server/xmpp/router/StreamError.java @@ -0,0 +1,44 @@ +package com.juick.server.xmpp.router; + +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + +import java.io.IOException; + + +/** + * Created by vitalyster on 03.02.2017. + */ +public class StreamError { + + private String condition; + + public StreamError() {} + + public StreamError(String condition) { + this.condition = condition; + } + + 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); + } + } + return streamError; + } + + public String getCondition() { + return condition; + } + + @Override + public String toString() { + return String.format("<stream:error><%s xmlns='%s'/></stream:error>", condition, StreamNamespaces.NS_XMPP_STREAMS); + } +} |