Schema für Topic geändert

This commit is contained in:
Sven committed 2024-05-14 09:39:53 +02:00
1 parent 7c2f5369ab
commit 4b8ac028bc
3 files changed
+42 -60

No files matched your search

+1 -1
View File
@@ -42,7 +42,7 @@ Future<void> main() async {
LogEntrySchema,
RankingSchema,
PictureSchema
], directory: dir.path);
], directory: dir.path, name: "database_v1");
runZonedGuarded(() {}, (error, stackTrace) {
_traceUncaughtExceptions(error, stackTrace);
+40 -58
View File
@@ -136,25 +136,12 @@ class MqttCore {
}
}
publishBinary(String topic, List<int> data) {
if (_mqttClient != null) {
var buffer = Uint8Buffer();
buffer.addAll(data);
_mqttClient!.publishMessage(topic, MqttQos.exactlyOnce, buffer);
Util.logInfo("binary message send to $topic");
} else {
Util.logException("publishBinary called while offline!");
}
}
bool _publishText(String topic, String text, {bool enqueueOnError = true}) {
try {
var buffer = Uint8Buffer();
buffer.addAll(GZipEncoder().encode(const Utf8Encoder().convert(text)) as Iterable<int>);
var messageTopic = "$_toServerTopic$topic/$_clientId";
var messageTopic = "$_toServerTopic$_clientId/$topic";
_mqttClient!.publishMessage(messageTopic, MqttQos.exactlyOnce, buffer);
@@ -178,57 +165,55 @@ class MqttCore {
try {
final MqttPublishMessage message = mqttMessage.payload as MqttPublishMessage;
if (message.variableHeader!.topicName.endsWith(_clientId)) {
var messageBytes = message.payload.message;
String payload = utf8.decode(GZipDecoder().decodeBytes(messageBytes));
var messageBytes = message.payload.message;
String payload = utf8.decode(GZipDecoder().decodeBytes(messageBytes));
var topicArray = message.variableHeader?.topicName;
var topicArraySplited = topicArray!.split("/");
var topic = topicArraySplited[3];
var topicArray = message.variableHeader?.topicName;
var topicArraySplited = topicArray!.split("/");
var topic = topicArraySplited[6];
Util.logInfo('message received\ntopic: $topic\nmessage: $payload');
Util.logInfo('message received\ntopic: $topic\nmessage: $payload');
switch (topic) {
case 'session':
_sessionMessageReceived(jsonDecode(payload));
break;
switch (topic) {
case 'session':
_sessionMessageReceived(jsonDecode(payload));
break;
case 'status':
_statusMessageReceived(jsonDecode(payload));
break;
case 'status':
_statusMessageReceived(jsonDecode(payload));
break;
case 'ranking':
_rankingMessageReceived(jsonDecode(payload));
break;
case 'ranking':
_rankingMessageReceived(jsonDecode(payload));
break;
case 'job':
_jobMessageReceived(jsonDecode(payload));
break;
case 'job':
_jobMessageReceived(jsonDecode(payload));
break;
case 'job_del':
_jobDeleteReceived(jsonDecode(payload));
break;
case 'job_del':
_jobDeleteReceived(jsonDecode(payload));
break;
case 'sync_request':
_syncRequestReceived(jsonDecode(payload));
break;
case 'sync_request':
_syncRequestReceived(jsonDecode(payload));
break;
case 'location_status':
_locationStatusMessageReceived(jsonDecode(payload));
break;
case 'location_status':
_locationStatusMessageReceived(jsonDecode(payload));
break;
case "mssg":
_messageMessageReceived(jsonDecode(payload));
break;
case "mssg":
_messageMessageReceived(jsonDecode(payload));
break;
case "upload_device_log":
_messageUploadDeviceLogReceived(jsonDecode(payload));
break;
case "upload_device_log":
_messageUploadDeviceLogReceived(jsonDecode(payload));
break;
default:
Util.logInfo('Unknown topic: $topic');
break;
}
default:
Util.logInfo('Unknown topic: $topic');
break;
}
} catch (ex) {
Util.logException(ex.toString());
@@ -236,7 +221,7 @@ class MqttCore {
}
});
var fromServerTopic = "$_fromServerTopic#";
var fromServerTopic = "$_fromServerTopic$_clientId/#";
if (await Util.preferencesContainsKey(Constants.prefsPreviousMqttSubscription)) {
String previousMqttSubscription = await Util.preferencesGetString(Constants.prefsPreviousMqttSubscription, "") as String;
@@ -376,11 +361,8 @@ class MqttCore {
deviceLog.entries = logEintries;
var json = jsonEncode(deviceLog.toJson());
var stringBytes = utf8.encode(json);
var gzipBytes = GZipEncoder().encode(stringBytes);
var topic = "/log/${_toServerTopic.replaceAll("/app/", "").replaceAll("/to_server", "")}";
publishBinary(topic, gzipBytes!);
_publishText("device_log", json);
}
void _startBootstrapReconnectTimer() {
+1 -1
View File
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 306.0.0+306
version: 308.0.0+308
environment:
sdk: '>=2.19.6 <3.0.0'