mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-16 09:13:02 +08:00
24 lines
778 B
C#
24 lines
778 B
C#
// Licensed to the .NET Foundation under one or more agreements.
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System;
|
|
using System.Text;
|
|
|
|
namespace MQTTnet
|
|
{
|
|
public static class MqttApplicationMessageExtensions
|
|
{
|
|
public static string ConvertPayloadToString(this MqttApplicationMessage applicationMessage)
|
|
{
|
|
if (applicationMessage == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(applicationMessage));
|
|
}
|
|
|
|
var payloadSegment = applicationMessage.PayloadSegment;
|
|
return Encoding.UTF8.GetString(payloadSegment.Array, payloadSegment.Offset, payloadSegment.Count);
|
|
}
|
|
}
|
|
}
|