发布:3.1.13

This commit is contained in:
若汝棋茗
2025-07-14 22:17:09 +08:00
parent c9edaf2bc8
commit a679b82da0
5 changed files with 11 additions and 8 deletions

View File

@@ -10,6 +10,7 @@
// 感谢您的下载和使用
//------------------------------------------------------------------------------
using Newtonsoft.Json.Linq;
using System;
using System.Runtime.CompilerServices;
@@ -1655,4 +1656,4 @@ public sealed partial class TouchSocketBitConverter
}
#endregion
}
}

View File

@@ -16,11 +16,11 @@ using TouchSocket.Core;
namespace TouchSocket.Mqtt;
internal class MqttAdapter : CustomDataHandlingAdapter<MqttMessage>
public class MqttAdapter : CustomDataHandlingAdapter<MqttMessage>
{
public override bool CanSendRequestInfo => true;
public MqttProtocolVersion Version { get; private set; } = MqttProtocolVersion.Unknown;
public MqttProtocolVersion Version { get; private set; } = MqttProtocolVersion.V311;
protected override FilterResult Filter<TByteBlock>(ref TByteBlock byteBlock, bool beCached, ref MqttMessage request, ref int tempCapacity)
{
@@ -51,7 +51,7 @@ internal class MqttAdapter : CustomDataHandlingAdapter<MqttMessage>
byteBlock.Position = position;
mqttMessage.Unpack(ref byteBlock);
if (byteBlock.Position != position + remainingLength + 2)
if (byteBlock.Position != position + remainingLength + 1+MqttExtension.GetVariableByteIntegerCount((int)remainingLength))
{
throw new Exception("存在没有读取的数据");
}

View File

@@ -18,8 +18,8 @@ namespace TouchSocket.Mqtt;
public static class MqttUtility
{
public const string MqttProtocolName = "Mqtt";
public static ReadOnlySpan<byte> MqttProtocolNameSpan => Encoding.UTF8.GetBytes("Mqtt");
public const string MqttProtocolName = "MQTT";
public static ReadOnlySpan<byte> MqttProtocolNameSpan => Encoding.UTF8.GetBytes("MQTT");
public static IReadOnlyList<MqttUserProperty> EmptyUserProperties { get; } = [];
}

View File

@@ -40,13 +40,15 @@ internal ref struct VariableByteIntegerRecorder
if (lenCount > this.m_minimumCount)
{
var moveCount = lenCount - this.m_minimumCount;
//len += moveCount;
byteBlock.ExtendSize(moveCount);
var span = byteBlock.TotalMemory.Span.Slice(this.m_dataPosition);
ShiftWithRight(span, moveCount);
byteBlock.Position = this.m_startPosition;
MqttExtension.WriteVariableByteInteger(ref byteBlock, (uint)len);
byteBlock.SetLength(endPosition);
byteBlock.SetLength(endPosition+ moveCount);
byteBlock.SeekToEnd();
}
else