Fehlerkorrekturen und Erweiterungen

This commit is contained in:
Sven committed 2025-09-02 11:26:43 +02:00
1 parent a16a8fcf28
commit 1207d9c517
12 files changed
+158 -60

No files matched your search

+24
View File
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:math';
import 'package:archive/archive.dart';
@@ -274,6 +275,10 @@ class MqttCore with ProducerMixin, ConsumerMixin {
_messageAcknowledgeReceived(jsonDecode(payloadString));
break;
case "command/logout":
_commandLogoutReceived(jsonDecode(payloadString));
break;
default:
Util.logInfo('Unknown topic: $topic');
break;
@@ -724,6 +729,25 @@ class MqttCore with ProducerMixin, ConsumerMixin {
);
}
void _commandLogoutReceived(Map<String, dynamic> payload) {
try {
String timestamp = payload['timestamp'] ?? 'Unknown timestamp';
Util.logInfo('Command logout received with timestamp: $timestamp');
// Disconnect MQTT client gracefully
_disconnectMqttClient();
// Exit the application reliably
Future.delayed(const Duration(milliseconds: 500), () {
exit(0);
});
} catch (ex) {
Util.logException('Error processing logout command: ${ex.toString()}');
// Force exit even if there's an error
exit(0);
}
}
String _encapsulateMessage(String messageId, bool requiresAck, Map<String, dynamic> message) {
var messageHeader = MessageHeader();
messageHeader.messageId = messageId;