Skip to content

Commit

Permalink
MqttPacketInspector: add FillReceiveBuffer(ReadOnlySequence<byte>) me…
Browse files Browse the repository at this point in the history
…thod.
  • Loading branch information
xljiulang committed Dec 6, 2024
1 parent 8df3a96 commit f2a81ea
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Source/MQTTnet/Adapter/MqttPacketInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Buffers;
using System.IO;
using System.Threading.Tasks;
using MQTTnet.Diagnostics.Logger;
Expand Down Expand Up @@ -81,6 +82,22 @@ public void FillReceiveBuffer(ReadOnlySpan<byte> buffer)
_receivedPacketBuffer?.Write(buffer);
}

public void FillReceiveBuffer(ReadOnlySequence<byte> buffer)
{
if (!_asyncEvent.HasHandlers)
{
return;
}

if (_receivedPacketBuffer != null)
{
foreach (var memory in buffer)
{
_receivedPacketBuffer.Write(memory.Span);
}
}
}

async Task InspectPacket(byte[] buffer, MqttPacketFlowDirection direction)
{
try
Expand Down

0 comments on commit f2a81ea

Please sign in to comment.