You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using MQTTnet.Exceptions;
- using MQTTnet.Protocol;
-
- namespace MQTTnet
- {
- public class TopicFilterBuilder
- {
- private MqttQualityOfServiceLevel _qualityOfServiceLevel = MqttQualityOfServiceLevel.AtMostOnce;
- private string _topic;
-
- public TopicFilterBuilder WithTopic(string topic)
- {
- _topic = topic;
- return this;
- }
-
- public TopicFilterBuilder WithQualityOfServiceLevel(MqttQualityOfServiceLevel qualityOfServiceLevel)
- {
- _qualityOfServiceLevel = qualityOfServiceLevel;
- return this;
- }
-
- public TopicFilterBuilder WithAtLeastOnceQoS()
- {
- _qualityOfServiceLevel = MqttQualityOfServiceLevel.AtLeastOnce;
- return this;
- }
-
- public TopicFilterBuilder WithAtMostOnceQoS()
- {
- _qualityOfServiceLevel = MqttQualityOfServiceLevel.AtMostOnce;
- return this;
- }
-
- public TopicFilterBuilder WithExactlyOnceQoS()
- {
- _qualityOfServiceLevel = MqttQualityOfServiceLevel.ExactlyOnce;
- return this;
- }
-
- public TopicFilter Build()
- {
- if (string.IsNullOrEmpty(_topic))
- {
- throw new MqttProtocolViolationException("Topic is not set.");
- }
-
- return new TopicFilter(_topic, _qualityOfServiceLevel);
- }
- }
- }
|