Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

MqttApplicationMessageExtensions.cs 1.0 KiB

12345678910111213141516171819202122232425262728293031323334
  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. publishPacket.Topic,
  10. publishPacket.Payload,
  11. publishPacket.QualityOfServiceLevel,
  12. publishPacket.Retain
  13. );
  14. }
  15. public static MqttPublishPacket ToPublishPacket(this MqttApplicationMessage applicationMessage)
  16. {
  17. if (applicationMessage == null)
  18. {
  19. return null;
  20. }
  21. return new MqttPublishPacket
  22. {
  23. Topic = applicationMessage.Topic,
  24. Payload = applicationMessage.Payload,
  25. QualityOfServiceLevel = applicationMessage.QualityOfServiceLevel,
  26. Retain = applicationMessage.Retain,
  27. Dup = false
  28. };
  29. }
  30. }
  31. }