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.
 
 
 
 

26 rindas
696 B

  1. using System;
  2. using System.Text;
  3. namespace MQTTnet
  4. {
  5. public static class MqttApplicationMessageExtensions
  6. {
  7. public static string ConvertPayloadToString(this MqttApplicationMessage applicationMessage)
  8. {
  9. if (applicationMessage == null) throw new ArgumentNullException(nameof(applicationMessage));
  10. if (applicationMessage.Payload == null)
  11. {
  12. return null;
  13. }
  14. if (applicationMessage.Payload.Length == 0)
  15. {
  16. return string.Empty;
  17. }
  18. return Encoding.UTF8.GetString(applicationMessage.Payload, 0, applicationMessage.Payload.Length);
  19. }
  20. }
  21. }