25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

36 lines
1.1 KiB

  1. using MQTTnet.Core.Packets;
  2. namespace MQTTnet.Core.Internal
  3. {
  4. internal static class MqttApplicationMessageExtensions
  5. {
  6. public static MqttApplicationMessage ToApplicationMessage(this MqttPublishPacket publishPacket)
  7. {
  8. return new MqttApplicationMessage
  9. {
  10. Topic = publishPacket.Topic,
  11. Payload = publishPacket.Payload,
  12. QualityOfServiceLevel = publishPacket.QualityOfServiceLevel,
  13. Retain = publishPacket.Retain
  14. };
  15. }
  16. public static MqttPublishPacket ToPublishPacket(this MqttApplicationMessage applicationMessage)
  17. {
  18. if (applicationMessage == null)
  19. {
  20. return null;
  21. }
  22. return new MqttPublishPacket
  23. {
  24. Topic = applicationMessage.Topic,
  25. Payload = applicationMessage.Payload,
  26. QualityOfServiceLevel = applicationMessage.QualityOfServiceLevel,
  27. Retain = applicationMessage.Retain,
  28. Dup = false
  29. };
  30. }
  31. }
  32. }