use of org.jxmpp.xml.splitter.XmppXmlSplitter 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;
}
use of org.jxmpp.xml.splitter.XmppXmlSplitter 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;
}
Aggregations