Erweiterungen

This commit is contained in:
Sven committed 2024-01-19 11:24:09 +01:00
1 parent 86414f4d0e
commit dbe821b08d
1 file changed
+7 -43
+7 -43
View File
@@ -48,7 +48,6 @@ class MqttCore {
try {
String clientId = await Util.getAppUuid();
Util.logInfo("client id: $clientId");
Util.logInfo("broker uri: $_brokerUri");
Util.logInfo("broker port: $_brokerPort");
@@ -59,10 +58,10 @@ class MqttCore {
_mqttClient.onDisconnected = _clientDisconnected;
_mqttClient.connectionMessage = MqttConnectMessage()
.withClientIdentifier('clientId')
.withClientIdentifier(await Util.getAppUuid())
.withWillQos(MqttQos.atMostOnce)
//.withWillTopic('willTopic')
//.withWillMessage('willMessage')
.withWillTopic('willTopic')
.withWillMessage('willMessage')
.authenticateAs("app", "apppwd");
await _mqttClient.connect();
@@ -215,7 +214,7 @@ class MqttCore {
var handshakeMessage = BootstrapRequest();
handshakeMessage.app = "sb";
handshakeMessage.mqttClientId = "12345";
handshakeMessage.mqttClientId = await Util.getAppUuid();
handshakeMessage.deviceObject = deviceObject;
handshakeMessage.ver = 200;
@@ -253,51 +252,16 @@ class MqttCore {
var jsonMap = startSessionMessage.toJson();
var json = jsonEncode(jsonMap);
Util.logInfo("json: $json");
Util.logInfo("send start session json: $json");
final builder = MqttClientPayloadBuilder();
builder.addString(json);
var payload = builder.payload;
var topic = "$_toServerTopic/init";
Util.logInfo("topic: $topic");
Util.logInfo("send start session json to topic: $topic");
var messageId = _mqttClient.publishMessage(topic, MqttQos.exactlyOnce, payload!);
Util.logInfo("messageId: $messageId");
Util.logInfo("send start session json with messageId: $messageId");
}
/*
private async void StartSession()
{
App.Logger.Debug("StartSession called");
App.Logger.Debug("Setting state to start session");
_mqttState = MqttStateEnum.StartSession;
var startSession = new JObject
{
new JProperty("recv", "server"),
new JProperty("store", true),
new JProperty("id", Guid.NewGuid().ToString()),
new JProperty("payload", new JObject(
new JProperty("start_session", "true")))
};
var json = JsonConvert.SerializeObject(startSession);
var topic = _toServerTopic + "/init";
var message = new MqttApplicationMessage()
{
Topic = topic,
Payload = Encoding.UTF8.GetBytes(json),
QualityOfServiceLevel = MqttQualityOfServiceLevel.ExactlyOnce,
Retain = true,
MessageExpiryInterval = 3600,
};
await _mqttClient.PublishAsync(message);
App.Logger.Debug("StartSession message " + json + " published to " + topic);
SendEnqueuedMessages();
}
*/
}