mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-28 09:12:37 +08:00
Add missing "WithWill..." methods.
This commit is contained in:
@@ -1 +1,2 @@
|
|||||||
* [Client] Fixed MQTTv5 protocol violation in PUBLISH packets (#1423).
|
* [Client] Fixed MQTTv5 protocol violation in PUBLISH packets (#1423).
|
||||||
|
* [Client] Added missing "WithWill..." methods in _MqttClientOptionsBuilder_.
|
||||||
@@ -380,6 +380,17 @@ namespace MQTTnet.Client
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MqttClientOptionsBuilder WithWillPayload(string willPayload)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(willPayload))
|
||||||
|
{
|
||||||
|
return WithWillPayload((byte[])null);
|
||||||
|
}
|
||||||
|
|
||||||
|
_options.WillPayload = Encoding.UTF8.GetBytes(willPayload);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public MqttClientOptionsBuilder WithWillQualityOfServiceLevel(MqttQualityOfServiceLevel willQualityOfServiceLevel)
|
public MqttClientOptionsBuilder WithWillQualityOfServiceLevel(MqttQualityOfServiceLevel willQualityOfServiceLevel)
|
||||||
{
|
{
|
||||||
_options.WillQualityOfServiceLevel = willQualityOfServiceLevel;
|
_options.WillQualityOfServiceLevel = willQualityOfServiceLevel;
|
||||||
@@ -391,5 +402,46 @@ namespace MQTTnet.Client
|
|||||||
_options.WillTopic = willTopic;
|
_options.WillTopic = willTopic;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MqttClientOptionsBuilder WithWillRetain(bool willRetain = true)
|
||||||
|
{
|
||||||
|
_options.WillRetain = willRetain;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MqttClientOptionsBuilder WithWillContentType(string willContentType)
|
||||||
|
{
|
||||||
|
_options.WillContentType = willContentType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MqttClientOptionsBuilder WithWillCorrelationData(byte[] willCorrelationData)
|
||||||
|
{
|
||||||
|
_options.WillCorrelationData = willCorrelationData;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MqttClientOptionsBuilder WithWillResponseTopic(string willResponseTopic)
|
||||||
|
{
|
||||||
|
_options.WillResponseTopic = willResponseTopic;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MqttClientOptionsBuilder WithWillPayloadFormatIndicator(MqttPayloadFormatIndicator willPayloadFormatIndicator)
|
||||||
|
{
|
||||||
|
_options.WillPayloadFormatIndicator = willPayloadFormatIndicator;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MqttClientOptionsBuilder WithWillUserProperty(string name, string value)
|
||||||
|
{
|
||||||
|
if (_options.WillUserProperties == null)
|
||||||
|
{
|
||||||
|
_options.WillUserProperties = new List<MqttUserProperty>();
|
||||||
|
}
|
||||||
|
|
||||||
|
_options.WillUserProperties.Add(new MqttUserProperty(name, value));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user