mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-16 17:23:04 +08:00
Expose results of publish operations for MQTTv5.
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using MQTTnet.Packets;
|
||||
|
||||
namespace MQTTnet.Client.Publishing
|
||||
{
|
||||
public class MqttClientPublishResult
|
||||
{
|
||||
public MqttClientPublishReasonCode ReasonCode { get; set; } = MqttClientPublishReasonCode.Success;
|
||||
|
||||
public string ReasonString { get; set; }
|
||||
|
||||
public List<MqttUserProperty> UserProperties { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,9 +191,12 @@ namespace MQTTnet.Formatter.V5
|
||||
{
|
||||
var result = new MqttClientPublishResult
|
||||
{
|
||||
ReasonCode = (MqttClientPublishReasonCode)pubAckPacket.ReasonCode
|
||||
// Both enums share the same values.
|
||||
ReasonCode = (MqttClientPublishReasonCode)pubAckPacket.ReasonCode.Value,
|
||||
ReasonString = pubAckPacket.Properties?.ReasonString,
|
||||
UserProperties = pubAckPacket.Properties?.UserProperties
|
||||
};
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -207,19 +210,24 @@ namespace MQTTnet.Formatter.V5
|
||||
};
|
||||
}
|
||||
|
||||
// The PUBCOMP is the last packet in QoS 2. So we use the results from that instead of PUBREC.
|
||||
if (pubCompPacket.ReasonCode == MqttPubCompReasonCode.PacketIdentifierNotFound)
|
||||
{
|
||||
return new MqttClientPublishResult
|
||||
{
|
||||
ReasonCode = MqttClientPublishReasonCode.UnspecifiedError
|
||||
ReasonCode = MqttClientPublishReasonCode.UnspecifiedError,
|
||||
ReasonString = pubCompPacket.Properties?.ReasonString,
|
||||
UserProperties = pubCompPacket.Properties?.UserProperties
|
||||
};
|
||||
}
|
||||
|
||||
var result = new MqttClientPublishResult
|
||||
{
|
||||
ReasonCode = MqttClientPublishReasonCode.Success
|
||||
ReasonCode = MqttClientPublishReasonCode.Success,
|
||||
ReasonString = pubCompPacket.Properties?.ReasonString,
|
||||
UserProperties = pubCompPacket.Properties?.UserProperties
|
||||
};
|
||||
|
||||
|
||||
if (pubRecPacket.ReasonCode.HasValue)
|
||||
{
|
||||
// Both enums share the same values.
|
||||
|
||||
Reference in New Issue
Block a user