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