mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-15 00:15:15 +08:00
Merge branch 'master' into 1413-protocol-version-132-mqtt-311-bridge-support
This commit is contained in:
@@ -393,6 +393,17 @@ namespace MQTTnet.Client
|
||||
_options.WillPayload = willPayload;
|
||||
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)
|
||||
{
|
||||
@@ -405,5 +416,46 @@ namespace MQTTnet.Client
|
||||
_options.WillTopic = willTopic;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,11 @@ namespace MQTTnet.Formatter.V5
|
||||
{
|
||||
// If absent, the Application Message does not expire.
|
||||
// This library uses 0 to indicate no expiration.
|
||||
if (value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
WriteAsFourByteInteger(MqttPropertyId.MessageExpiryInterval, value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user