Class MqttTopicMatcher
- Namespace
- Kuestenlogik.Bowire.Protocol.Mqtt.Mock
- Assembly
- Kuestenlogik.Bowire.Protocol.Mqtt.dll
MQTT topic-pattern matcher. Supports the two wildcards the MQTT spec defines on subscriptions:
+— exactly one level (e.g.sensors/+/tempmatchessensors/room1/tempbut notsensors/a/b/temp).#— zero or more trailing levels, must be the last segment (e.g.sensors/#matchessensors,sensors/a,sensors/a/b/c).
On a successful match, the positional wildcard values are returned
so callers can expose them to the dynamic-value substitutor as
\({topic.0}</code>, <code>\){topic.1}, …, and the # tail as
${topic.rest}.
public static class MqttTopicMatcher
- Inheritance
-
MqttTopicMatcher
- Inherited Members
Methods
IsPattern(string?)
True when the given pattern carries at least one wildcard (+ or #).
public static bool IsPattern(string? pattern)
Parameters
patternstring
Returns
TryMatch(string?, string, out Dictionary<string, string>)
Test whether topic (a concrete MQTT topic)
satisfies pattern (a pattern that may carry
+ / # wildcards), and collect the wildcard
bindings.
public static bool TryMatch(string? pattern, string topic, out Dictionary<string, string> bindings)
Parameters
patternstringPattern from the recorded step, e.g.
cmd/+/set.topicstringConcrete topic from the incoming publish.
bindingsDictionary<string, string>When the match succeeds, populated with (positional key → captured segment).
+wildcards contribute"0"/"1"/... by position; the trailing#wildcard also contributes"rest"with the full remainder of the topic. Empty when a literal pattern matches its literal topic.
Returns
- bool
trueon match,falseotherwise.