From 3208045baab5ecb37f0a9aee5a96eb606a00f10b Mon Sep 17 00:00:00 2001 From: Christian Kratky Date: Fri, 30 Oct 2020 20:42:52 +0100 Subject: [PATCH] Extend application message builder. --- Source/MQTTnet/MqttApplicationMessageBuilder.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/MQTTnet/MqttApplicationMessageBuilder.cs b/Source/MQTTnet/MqttApplicationMessageBuilder.cs index c265e4d1..bc2d9b86 100644 --- a/Source/MQTTnet/MqttApplicationMessageBuilder.cs +++ b/Source/MQTTnet/MqttApplicationMessageBuilder.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; @@ -103,6 +104,16 @@ namespace MQTTnet return this; } + public MqttApplicationMessageBuilder WithQualityOfServiceLevel(int qualityOfServiceLevel) + { + if (qualityOfServiceLevel < 0 || qualityOfServiceLevel > 2) + { + throw new ArgumentOutOfRangeException(nameof(qualityOfServiceLevel)); + } + + return WithQualityOfServiceLevel((MqttQualityOfServiceLevel)qualityOfServiceLevel); + } + public MqttApplicationMessageBuilder WithRetainFlag(bool value = true) { _retain = value;