removed dead code and make new connection context an opt in so kestrel 2.0 still works

This commit is contained in:
JanEggers
2018-06-16 17:20:01 +02:00
parent d5ac8c7183
commit 7c2adf636f
4 changed files with 19 additions and 66 deletions
@@ -97,46 +97,12 @@ namespace MQTTnet.AspNetCore
{
foreach (var packet in packets)
{
await WriteAsync(packet);
var buffer = PacketSerializer.Serialize(packet);
await Connection.Transport.Output.WriteAsync(buffer.AsMemory());
}
}
public async Task WriteAsync(MqttBasePacket packet)
{
var buffer = PacketSerializer.Serialize(packet);
await Connection.Transport.Output.WriteAsync(buffer.AsMemory());
}
private int messageId;
public event EventHandler ReadingPacketStarted;
public event EventHandler ReadingPacketCompleted;
public Task PublishAsync(MqttPublishPacket packet)
{
if (!packet.PacketIdentifier.HasValue && packet.QualityOfServiceLevel > MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce)
{
packet.PacketIdentifier = (ushort)Interlocked.Increment(ref messageId);
}
return WriteAsync(packet);
}
public Task SubscribeAsync(MqttSubscribePacket packet)
{
if (!packet.PacketIdentifier.HasValue)
{
packet.PacketIdentifier = (ushort)Interlocked.Increment(ref messageId);
}
return WriteAsync(packet);
}
public Task ConnectAsync(MqttConnectPacket packet)
{
if (string.IsNullOrEmpty(packet.ClientId))
{
packet.ClientId = Guid.NewGuid().ToString();
}
return WriteAsync(packet);
}
}
}