Erweiterungen
This commit is contained in:
1 parent
23693f47a4
commit
f764503d7e
1 file changed
+9
-3
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:isar/isar.dart';
|
import 'package:isar/isar.dart';
|
||||||
@@ -130,12 +131,17 @@ class MqttCore {
|
|||||||
|
|
||||||
publishText(String subtopic, String text) {
|
publishText(String subtopic, String text) {
|
||||||
try {
|
try {
|
||||||
var buffer = Uint8Buffer();
|
var textBuffer = Uint8Buffer();
|
||||||
buffer.addAll(text.codeUnits);
|
textBuffer.addAll(text.codeUnits);
|
||||||
|
|
||||||
|
var compressedText = GZipCodec().encode(text.codeUnits);
|
||||||
|
|
||||||
|
var mqttBuffer = Uint8Buffer();
|
||||||
|
mqttBuffer.addAll(compressedText);
|
||||||
|
|
||||||
var topic = "$_toServerTopic$subtopic/$_clientId";
|
var topic = "$_toServerTopic$subtopic/$_clientId";
|
||||||
|
|
||||||
_mqttClient.publishMessage( topic, MqttQos.exactlyOnce, buffer);
|
_mqttClient.publishMessage( topic, MqttQos.exactlyOnce, mqttBuffer);
|
||||||
|
|
||||||
Util.logInfo("send message $text to $topic");
|
Util.logInfo("send message $text to $topic");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in new issue
Block a user