log duplication fix

main
Peace 9 months ago
parent 7ec6f7dccc
commit c04024e9b4
  1. 2
      MQTTSample/MqttMultiTopicClientApp/Program.cs
  2. 6
      MQTTSample/PMqttClient/MqttMultiTopicClient.cs

@ -17,6 +17,8 @@ namespace MqttMultiTopicClientApp
await _mqttClient.AddTopicAsync("home/livingroom/temperature", MqttQoSLevel.AtLeastOnce);
await Task.Delay(1000);
await _mqttClient.ConnectAsync(SERVER_IP, PORT, $"cid_{Random.Shared.Next(1, 1000)}");
await _mqttClient.AddTopicAsync("home/bedroom/humidity", MqttQoSLevel.AtMostOnce);

@ -53,8 +53,6 @@ namespace PMqttClient
_topics.Add(topic, qos);
if (_mqttClient.IsConnected)
await SubscribeAsync(topic, qos);
WriteLog($"topic '{topic}' is added.");
}
public async Task RemoveTopicAsync(string topic)
@ -107,11 +105,7 @@ namespace PMqttClient
WriteLog("Connected to MQTT Broker.");
foreach (var topic in _topics)
{
await SubscribeAsync(topic.Key, topic.Value);
WriteLog($"Subscribed to topic: {topic.Key} with QoS {topic.Value.ToString()}.");
}
}
private void WriteLog(string message)

Loading…
Cancel
Save