You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MqttApplicationMessageExtensions.cs 696 B

пре 6 година
12345678910111213141516171819202122232425
  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. }