Comments and UI Logik added

This commit is contained in:
naumueller 2025-11-02 19:10:32 +01:00
parent e4276d6cca
commit 1eb9ee4624
2 changed files with 11 additions and 8 deletions

View File

@ -89,7 +89,7 @@ public class MqttJavaClient implements MqttCallback {
System.out.println(" Inhalt: " + new String(message.getPayload())); System.out.println(" Inhalt: " + new String(message.getPayload()));
System.out.println(" QoS: " + message.getQos()); System.out.println(" QoS: " + message.getQos());
Consumer<String> listener = topicListeners.get(topic); Consumer<String> listener = topicListeners.get(topic); // Consumer<String> aus HashMap holen
if (listener != null) { if (listener != null) {
listener.accept(payload); listener.accept(payload);
} }

View File

@ -32,8 +32,11 @@ public class FxViewModel {
} }
public void subscribeTopic(String topic) { public void subscribeTopic(String topic) {
model.getMqttClient().addTopicListeners(topic, msg -> { model.getMqttClient().addTopicListeners(topic, msg -> { // Consumer<String> mit Lambda-Funktion (wird ausgeführt, wenn message für topic ankommt)
Platform.runLater(() -> getTopicProperty(topic).set(msg)); Platform.runLater(() -> {
getTopicProperty(topic).set(msg); // Richtige Property für topic aus HashMap holen und Message anzeigen.
incomingMessage.set(msg);
});
}); });
} }