From 660207485a359acbec6ad870c88c2ed456c6eda0 Mon Sep 17 00:00:00 2001 From: Gregor_Dutzler Date: Fri, 11 Oct 2019 16:14:05 +0200 Subject: [PATCH] mqttfertig --- src/com/wasteinformationserver/main.java | 12 ++++-------- src/com/wasteinformationserver/mqtt/mqtt.java | 5 +++-- .../wasteinformationserver/mqtt/mqtttransmitter.java | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/com/wasteinformationserver/main.java b/src/com/wasteinformationserver/main.java index 8f2bfbc..6bcbc07 100644 --- a/src/com/wasteinformationserver/main.java +++ b/src/com/wasteinformationserver/main.java @@ -6,11 +6,8 @@ import com.wasteinformationserver.website.Webserver; public class main { public static void main(String[] args) { -/* - com.wasteinformationserver.Date D=new com.wasteinformationserver.Date(); - D.getdata(); - D.printList(); - */ + + Runtime.getRuntime().addShutdownHook(new Thread(() -> { try { @@ -28,9 +25,8 @@ public class main { Log.message("thread started"); -// mqtt m = new mqtt(); -// m.notifymessage(); -// m.getDatabasedata(); + mqtt m = new mqtt(); + m.notifymessage(); } } diff --git a/src/com/wasteinformationserver/mqtt/mqtt.java b/src/com/wasteinformationserver/mqtt/mqtt.java index 62c9152..df8e0a8 100644 --- a/src/com/wasteinformationserver/mqtt/mqtt.java +++ b/src/com/wasteinformationserver/mqtt/mqtt.java @@ -107,9 +107,10 @@ public class mqtt { } - private void transmitmessageAbfallart(String tempabfallart) { + private void transmitmessageAbfallart(String temp) { mqtttransmitter mt = new mqtttransmitter(); - mt.sendmessage(tempabfallart); + System.out.println(temp); + mt.sendmessage(temp); } } \ No newline at end of file diff --git a/src/com/wasteinformationserver/mqtt/mqtttransmitter.java b/src/com/wasteinformationserver/mqtt/mqtttransmitter.java index e158bf9..25702f7 100644 --- a/src/com/wasteinformationserver/mqtt/mqtttransmitter.java +++ b/src/com/wasteinformationserver/mqtt/mqtttransmitter.java @@ -39,7 +39,7 @@ public class mqtttransmitter { System.out.println("Message published"); sampleClient.disconnect(); System.out.println("Disconnected"); - System.exit(0); + } catch (MqttException me) { System.out.println("reason " + me.getReasonCode());