Erweiterungen

This commit is contained in:
Sven committed 2026-02-14 09:03:34 +01:00
1 parent bb3dc9e856
commit 4961aec177
1 file changed
+6 -28
+6 -28
View File
@@ -143,16 +143,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
Uint8Buffer uint8Buffer = Uint8Buffer(); Uint8Buffer uint8Buffer = Uint8Buffer();
uint8Buffer.addAll(willMessageUtf8); uint8Buffer.addAll(willMessageUtf8);
_mqttClient!.connectionMessage = MqttConnectMessage() _mqttClient!.connectionMessage = MqttConnectMessage().withClientIdentifier(Util.getAppUuid()).authenticateAs("app", "apppwd").withSessionExpiryInterval(2700).withWillProperties(willProperties).withWillTopic("$_toServerTopic$_clientId/connection_lost").withWillQos(MqttQos.atMostOnce).keepAliveFor(60).withWillPayload(uint8Buffer).will();
.withClientIdentifier(Util.getAppUuid())
.authenticateAs("app", "apppwd")
.withSessionExpiryInterval(2700)
.withWillProperties(willProperties)
.withWillTopic("$_toServerTopic$_clientId/connection_lost")
.withWillQos(MqttQos.atMostOnce)
.keepAliveFor(60)
.withWillPayload(uint8Buffer)
.will();
} }
await _mqttClient!.connect(); await _mqttClient!.connect();
@@ -227,9 +218,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
var topicArray = message.variableHeader?.topicName; var topicArray = message.variableHeader?.topicName;
var topicArraySplited = topicArray!.split("/"); var topicArraySplited = topicArray!.split("/");
var topic = topicArraySplited.length > 7 var topic = topicArraySplited.length > 7 ? topicArraySplited.sublist(7).join('/') : (topicArraySplited.length == 8 ? topicArraySplited[7] : "");
? topicArraySplited.sublist(7).join('/')
: (topicArraySplited.length == 8 ? topicArraySplited[7] : "");
if (topic.endsWith('/')) { if (topic.endsWith('/')) {
topic = topic.substring(0, topic.length - 1); topic = topic.substring(0, topic.length - 1);
} }
@@ -385,10 +374,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
box.removeAll(); box.removeAll();
box.put(ranking); box.put(ranking);
sendMessage( sendMessage(routingKey: Constants.messageTopicRankingUpdated, payload: RankingUpdated());
routingKey: Constants.messageTopicRankingUpdated,
payload: RankingUpdated(),
);
} }
void _jobMessageReceived(payloadData) async { void _jobMessageReceived(payloadData) async {
@@ -408,9 +394,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
// Ensure files are updated even if the job already exists // Ensure files are updated even if the job already exists
// This handles migration from old app versions without files support // This handles migration from old app versions without files support
if (payloadData['files'] != null) { if (payloadData['files'] != null) {
newJob.files = (payloadData['files'] as List<dynamic>) newJob.files = (payloadData['files'] as List<dynamic>).map((e) => TourFile.fromJson(e as Map<String, dynamic>)).toList();
.map((e) => TourFile.fromJson(e as Map<String, dynamic>))
.toList();
} }
} }
@@ -478,10 +462,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
var deviceLogRequest = DeviceLogRequest.fromJson(payloadData); var deviceLogRequest = DeviceLogRequest.fromJson(payloadData);
final box = MyApp.objectBoxStore.box<LogEntry>(); final box = MyApp.objectBoxStore.box<LogEntry>();
final query = box.query( final query = box.query(LogEntry_.time.greaterThan(deviceLogRequest.startDateTime.millisecondsSinceEpoch).and(LogEntry_.time.lessThan(deviceLogRequest.endDateTime.millisecondsSinceEpoch))).build();
LogEntry_.time.greaterThan(deviceLogRequest.startDateTime.millisecondsSinceEpoch)
.and(LogEntry_.time.lessThan(deviceLogRequest.endDateTime.millisecondsSinceEpoch))
).build();
var logEintries = query.find(); var logEintries = query.find();
query.close(); query.close();
@@ -502,7 +483,6 @@ class MqttCore with ProducerMixin, ConsumerMixin {
box.removeMany(messages.map((e) => e.id).toList()); box.removeMany(messages.map((e) => e.id).toList());
} }
void _startReconnectTimer() { void _startReconnectTimer() {
connectionState = ConnectionStateEnum.notConnected; connectionState = ConnectionStateEnum.notConnected;
@@ -663,7 +643,6 @@ class MqttCore with ProducerMixin, ConsumerMixin {
} else { } else {
_publishMessage("track", <String, dynamic>{}, false); _publishMessage("track", <String, dynamic>{}, false);
} }
} catch (ex) { } catch (ex) {
Util.logException("Error in periodic track timer: {$ex}"); Util.logException("Error in periodic track timer: {$ex}");
} }
@@ -763,8 +742,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
void _commandLogoutReceived(Map<String, dynamic> payload) { void _commandLogoutReceived(Map<String, dynamic> payload) {
try { try {
String timestamp = payload['timestamp']?.toString() ?? 'Unknown timestamp'; Util.logInfo('Command logout received');
Util.logInfo('Command logout received with timestamp: $timestamp');
// Disconnect MQTT client gracefully // Disconnect MQTT client gracefully
_disconnectMqttClient(); _disconnectMqttClient();