improve exceptions in case of corrupt packages close pipes after exception occoured to avoid lingering connections should fix #788

This commit is contained in:
JanEggers
2020-07-09 21:19:00 +02:00
parent 6a564a0c72
commit 33e4ec1943
10 changed files with 134 additions and 21 deletions
@@ -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();
}
}
}