mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-15 00:15:15 +08:00
16 lines
482 B
C#
16 lines
482 B
C#
using MQTTnet.Protocol;
|
|
|
|
namespace MQTTnet.Formatter
|
|
{
|
|
public static class MqttPacketWriterExtensions
|
|
{
|
|
public static byte[] AddMqttHeader(this IMqttPacketWriter writer, MqttControlPacketType header, byte[] body)
|
|
{
|
|
writer.Write(MqttPacketWriter.BuildFixedHeader(header));
|
|
writer.WriteVariableLengthInteger((uint)body.Length);
|
|
writer.Write(body, 0, body.Length);
|
|
return writer.GetBuffer();
|
|
}
|
|
}
|
|
}
|