- System.out.println();
- }
- });
-
- dbusconnection.addSigHandler(Signal.ReceiptReceived.class,
- receiptReceived -> {
- if (jsonProcessor != null) {
- JsonMessageEnvelope envelope = new JsonMessageEnvelope(receiptReceived);
- ObjectNode result = jsonProcessor.createObjectNode();
- result.putPOJO("envelope", envelope);
- try {
- jsonProcessor.writeValue(System.out, result);
- System.out.println();
- } catch (IOException e) {
- e.printStackTrace();
- }
- } else {
- System.out.print(String.format("Receipt from: %s\nTimestamp: %s\n",
- receiptReceived.getSender(), DateUtils.formatTimestamp(receiptReceived.getTimestamp())));
- }
- });
-
- dbusconnection.addSigHandler(Signal.SyncMessageReceived.class, syncReceived -> {
- if (jsonProcessor != null) {
- JsonMessageEnvelope envelope = new JsonMessageEnvelope(syncReceived);
- ObjectNode result = jsonProcessor.createObjectNode();
- result.putPOJO("envelope", envelope);
- try {
- jsonProcessor.writeValue(System.out, result);
- System.out.println();
- } catch (IOException e) {
- e.printStackTrace();
- }
- } else {
- System.out.print(String.format("Sync Envelope from: %s to: %s\nTimestamp: %s\nBody: %s\n",
- syncReceived.getSource(), syncReceived.getDestination(), DateUtils.formatTimestamp(syncReceived.getTimestamp()), syncReceived.getMessage()));
+ writer.println();
+ });
+
+ dbusconnection.addSigHandler(Signal.ReceiptReceived.class, receiptReceived -> {
+ writer.println("Receipt from: {}", receiptReceived.getSender());
+ writer.println("Timestamp: {}", DateUtils.formatTimestamp(receiptReceived.getTimestamp()));
+ });
+
+ dbusconnection.addSigHandler(Signal.SyncMessageReceived.class, syncReceived -> {
+ writer.println("Sync Envelope from: {} to: {}",
+ syncReceived.getSource(),
+ syncReceived.getDestination());
+ writer.println("Timestamp: {}", DateUtils.formatTimestamp(syncReceived.getTimestamp()));
+ writer.println("Body: {}", syncReceived.getMessage());