mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-18 02:13:00 +08:00
improve exceptions in case of corrupt packages close pipes after exception occoured to avoid lingering connections should fix #788
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user