From bb106f8c6e288ba633f24a8e082147e5c6c729cb Mon Sep 17 00:00:00 2001 From: Christian <6939810+chkr1011@users.noreply.github.com> Date: Mon, 5 Dec 2022 19:21:08 +0100 Subject: [PATCH] Refactor code --- .../MqttConnectionContext.cs | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Source/MQTTnet.AspnetCore/MqttConnectionContext.cs b/Source/MQTTnet.AspnetCore/MqttConnectionContext.cs index 54c37a7b..a57df2d9 100644 --- a/Source/MQTTnet.AspnetCore/MqttConnectionContext.cs +++ b/Source/MQTTnet.AspnetCore/MqttConnectionContext.cs @@ -2,6 +2,11 @@ // 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.IO.Pipelines; +using System.Security.Cryptography.X509Certificates; +using System.Threading; +using System.Threading.Tasks; using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Http.Connections.Features; using MQTTnet.Adapter; @@ -10,11 +15,6 @@ using MQTTnet.Exceptions; using MQTTnet.Formatter; using MQTTnet.Internal; using MQTTnet.Packets; -using System; -using System.IO.Pipelines; -using System.Security.Cryptography.X509Certificates; -using System.Threading; -using System.Threading.Tasks; namespace MQTTnet.AspNetCore { @@ -187,14 +187,11 @@ namespace MQTTnet.AspNetCore } } - /// - /// copy MqttPacketBuffer's Packet and Payload to the same buffer block of PipeWriter - /// MqttPacket will be transmitted within the bounds of a WebSocket frame after PipeWriter.FlushAsync - /// - /// - /// - private static void WritePacketBuffer(PipeWriter output, MqttPacketBuffer buffer) + static void WritePacketBuffer(PipeWriter output, MqttPacketBuffer buffer) { + // copy MqttPacketBuffer's Packet and Payload to the same buffer block of PipeWriter + // MqttPacket will be transmitted within the bounds of a WebSocket frame after PipeWriter.FlushAsync + var span = output.GetSpan(buffer.Length); buffer.Packet.AsSpan().CopyTo(span);