Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

36 rader
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. }