Refactor output writers

This commit is contained in:
AsamK 2021-08-08 17:32:55 +02:00
parent f449a242e4
commit 48b2c7ff8a
42 changed files with 327 additions and 187 deletions

View file

@ -29,15 +29,15 @@ import static org.asamk.signal.util.Util.getLegacyIdentifier;
public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
final Manager m;
final PlainTextWriter writer;
public ReceiveMessageHandler(Manager m) {
public ReceiveMessageHandler(Manager m, final PlainTextWriter writer) {
this.m = m;
this.writer = writer;
}
@Override
public void handleMessage(SignalServiceEnvelope envelope, SignalServiceContent content, Throwable exception) {
PlainTextWriter writer = new PlainTextWriterImpl(System.out);
if (envelope.hasSource()) {
var source = envelope.getSourceAddress();
writer.println("Envelope from: {} (device: {})", formatContact(source), envelope.getSourceDevice());