Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

MqttApplicationMessageExtensions.cs 1.1 KiB

1234567891011121314151617181920212223242526272829303132333435
  1. using MQTTnet.Packets;
  2. namespace MQTTnet.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. }