Closed dwillie closed 8 years ago
There is no simple way. Only dirty solution:
let topic = message.topic.path.as_str();
if topic.len() >= 3 && &topic[..7] == "/stuff/" {
println!("subscribed to /stuff/#");
}
if topic.len() >= 23 && &topic[..23] == "/things/awesome_things/" {
println!("subscribed to /things/awesome_things/#");
}
The MQTT protocol doesn't provide any help for this.
I just wanted to check if you provide a method or have a recommendation on, how one would best go about ensuring – when a client is subscribed to multiple topics – which topic the incoming message matches to?
Eg. My client is subscribed to "/stuff/#" and "/things/awesome_things/#" and receives a message with the topic "/things/awesome_things/sandwich". How would I check which subscription topic the incoming message related to?
Sorry if that's a bit convoluted!