Search in sources :

Example 1 with XmlPrettyPrinter

use of org.jxmpp.xml.splitter.XmlPrettyPrinter in project Smack by igniterealtime.

the class SmackDebugger method newConnectionReader.

/**
 * Returns a new special Reader that wraps the new connection Reader. The connection
 * has been secured so the connection is using a new reader and writer. The debugger
 * needs to wrap the new reader and writer to keep being notified of the connection
 * traffic.
 *
 * @param reader connection reader.
 * @return a new special Reader that wraps the new connection Reader.
 */
public final Reader newConnectionReader(Reader reader) {
    XmlPrettyPrinter xmlPrettyPrinter = XmlPrettyPrinter.builder().setPrettyWriter(sb -> incomingStreamSink(sb)).build();
    incomingStreamSplitterForPrettyPrinting = new XmppXmlSplitter(xmlPrettyPrinter);
    ObservableReader observableReader = new ObservableReader(reader);
    observableReader.addReaderListener(readString -> {
        try {
            incomingStreamSplitterForPrettyPrinting.append(readString);
        } catch (IOException e) {
            throw new AssertionError(e);
        }
    });
    return observableReader;
}
Also used : TopLevelStreamElement(org.jivesoftware.smack.packet.TopLevelStreamElement) ObservableWriter(org.jivesoftware.smack.util.ObservableWriter) Writer(java.io.Writer) XmppXmlSplitter(org.jxmpp.xml.splitter.XmppXmlSplitter) IOException(java.io.IOException) ObservableReader(org.jivesoftware.smack.util.ObservableReader) Reader(java.io.Reader) EntityFullJid(org.jxmpp.jid.EntityFullJid) XMPPConnection(org.jivesoftware.smack.XMPPConnection) XmlPrettyPrinter(org.jxmpp.xml.splitter.XmlPrettyPrinter) XmppXmlSplitter(org.jxmpp.xml.splitter.XmppXmlSplitter) ObservableReader(org.jivesoftware.smack.util.ObservableReader) XmlPrettyPrinter(org.jxmpp.xml.splitter.XmlPrettyPrinter) IOException(java.io.IOException)

Example 2 with XmlPrettyPrinter

use of org.jxmpp.xml.splitter.XmlPrettyPrinter in project Smack by igniterealtime.

the class SmackDebugger method newConnectionWriter.

/**
 * Returns a new special Writer that wraps the new connection Writer. The connection
 * has been secured so the connection is using a new reader and writer. The debugger
 * needs to wrap the new reader and writer to keep being notified of the connection
 * traffic.
 *
 * @param writer connection writer.
 * @return a new special Writer that wraps the new connection Writer.
 */
public final Writer newConnectionWriter(Writer writer) {
    XmlPrettyPrinter xmlPrettyPrinter = XmlPrettyPrinter.builder().setPrettyWriter(sb -> outgoingStreamSink(sb)).build();
    outgoingStreamSplitterForPrettyPrinting = new XmppXmlSplitter(xmlPrettyPrinter);
    ObservableWriter observableWriter = new ObservableWriter(writer);
    observableWriter.addWriterListener(writtenString -> {
        try {
            outgoingStreamSplitterForPrettyPrinting.append(writtenString);
        } catch (IOException e) {
            throw new AssertionError(e);
        }
    });
    return observableWriter;
}
Also used : TopLevelStreamElement(org.jivesoftware.smack.packet.TopLevelStreamElement) ObservableWriter(org.jivesoftware.smack.util.ObservableWriter) Writer(java.io.Writer) XmppXmlSplitter(org.jxmpp.xml.splitter.XmppXmlSplitter) IOException(java.io.IOException) ObservableReader(org.jivesoftware.smack.util.ObservableReader) Reader(java.io.Reader) EntityFullJid(org.jxmpp.jid.EntityFullJid) XMPPConnection(org.jivesoftware.smack.XMPPConnection) XmlPrettyPrinter(org.jxmpp.xml.splitter.XmlPrettyPrinter) XmppXmlSplitter(org.jxmpp.xml.splitter.XmppXmlSplitter) ObservableWriter(org.jivesoftware.smack.util.ObservableWriter) XmlPrettyPrinter(org.jxmpp.xml.splitter.XmlPrettyPrinter) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)2 Reader (java.io.Reader)2 Writer (java.io.Writer)2 XMPPConnection (org.jivesoftware.smack.XMPPConnection)2 TopLevelStreamElement (org.jivesoftware.smack.packet.TopLevelStreamElement)2 ObservableReader (org.jivesoftware.smack.util.ObservableReader)2 ObservableWriter (org.jivesoftware.smack.util.ObservableWriter)2 EntityFullJid (org.jxmpp.jid.EntityFullJid)2 XmlPrettyPrinter (org.jxmpp.xml.splitter.XmlPrettyPrinter)2 XmppXmlSplitter (org.jxmpp.xml.splitter.XmppXmlSplitter)2