Pārlūkot izejas kodu

Refactoring

release/3.x.x
Christian Kratky pirms 7 gadiem
vecāks
revīzija
40dd620f90
3 mainītis faili ar 12 papildinājumiem un 3 dzēšanām
  1. +5
    -1
      MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs
  2. +6
    -1
      MQTTnet.Core/Adapter/ReceivedMqttPacket.cs
  3. +1
    -1
      MQTTnet.Core/Serializer/MqttPacketWriter.cs

+ 5
- 1
MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs Parādīt failu

@@ -139,9 +139,9 @@ namespace MQTTnet.Core.Adapter

public async Task<MqttBasePacket> ReceivePacketAsync(TimeSpan timeout, CancellationToken cancellationToken)
{
ReceivedMqttPacket receivedMqttPacket = null;
try
{
ReceivedMqttPacket receivedMqttPacket;
if (timeout > TimeSpan.Zero)
{
receivedMqttPacket = await ReceiveAsync(_channel.ReceiveStream, cancellationToken).TimeoutAfter(timeout).ConfigureAwait(false);
@@ -185,6 +185,10 @@ namespace MQTTnet.Core.Adapter
{
throw new MqttCommunicationException(exception);
}
finally
{
receivedMqttPacket?.Dispose();
}
}

private static async Task<ReceivedMqttPacket> ReceiveAsync(Stream stream, CancellationToken cancellationToken)


+ 6
- 1
MQTTnet.Core/Adapter/ReceivedMqttPacket.cs Parādīt failu

@@ -4,7 +4,7 @@ using MQTTnet.Core.Packets;

namespace MQTTnet.Core.Adapter
{
public class ReceivedMqttPacket
public sealed class ReceivedMqttPacket : IDisposable
{
public ReceivedMqttPacket(MqttPacketHeader header, MemoryStream body)
{
@@ -15,5 +15,10 @@ namespace MQTTnet.Core.Adapter
public MqttPacketHeader Header { get; }

public MemoryStream Body { get; }

public void Dispose()
{
Body?.Dispose();
}
}
}

+ 1
- 1
MQTTnet.Core/Serializer/MqttPacketWriter.cs Parādīt failu

@@ -9,7 +9,7 @@ namespace MQTTnet.Core.Serializer
public sealed class MqttPacketWriter : BinaryWriter
{
public MqttPacketWriter(Stream stream)
: base(stream)
: base(stream, Encoding.UTF8, true)
{
}



Notiek ielāde…
Atcelt
Saglabāt