Add interfaces, optimize performance, fix QoS level 2

This commit is contained in:
Christian Kratky
2017-08-05 11:37:52 +02:00
parent 0b0239bcf1
commit 447ca6cabb
27 changed files with 199 additions and 148 deletions
+1 -20
View File
@@ -1,25 +1,6 @@
using System;
namespace MQTTnet.Core.Packets
namespace MQTTnet.Core.Packets
{
public abstract class MqttBasePacket
{
public TResponsePacket CreateResponse<TResponsePacket>()
{
var responsePacket = Activator.CreateInstance<TResponsePacket>();
var responsePacketWithIdentifier = responsePacket as IPacketWithIdentifier;
if (responsePacketWithIdentifier != null)
{
var requestPacketWithIdentifier = this as IPacketWithIdentifier;
if (requestPacketWithIdentifier == null)
{
throw new InvalidOperationException("Response packet has PacketIdentifier but request packet does not.");
}
responsePacketWithIdentifier.PacketIdentifier = requestPacketWithIdentifier.PacketIdentifier;
}
return responsePacket;
}
}
}