mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-15 00:15:15 +08:00
32 lines
1.3 KiB
C#
32 lines
1.3 KiB
C#
// Licensed to the .NET Foundation under one or more agreements.
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using MQTTnet.Packets;
|
|
|
|
namespace MQTTnet.Formatter;
|
|
|
|
public static class MqttApplicationMessageFactory
|
|
{
|
|
public static MqttApplicationMessage Create(MqttPublishPacket publishPacket)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(publishPacket);
|
|
|
|
return new MqttApplicationMessage
|
|
{
|
|
Topic = publishPacket.Topic,
|
|
Payload = publishPacket.Payload,
|
|
QualityOfServiceLevel = publishPacket.QualityOfServiceLevel,
|
|
Retain = publishPacket.Retain,
|
|
Dup = publishPacket.Dup,
|
|
ResponseTopic = publishPacket.ResponseTopic,
|
|
ContentType = publishPacket.ContentType,
|
|
CorrelationData = publishPacket.CorrelationData.ToArray(),
|
|
MessageExpiryInterval = publishPacket.MessageExpiryInterval,
|
|
SubscriptionIdentifiers = publishPacket.SubscriptionIdentifiers,
|
|
TopicAlias = publishPacket.TopicAlias,
|
|
PayloadFormatIndicator = publishPacket.PayloadFormatIndicator,
|
|
UserProperties = publishPacket.UserProperties
|
|
};
|
|
}
|
|
} |