Refactor property definition for packets.

This commit is contained in:
Christian Kratky
2018-11-23 22:50:44 +01:00
parent 7292cedd2f
commit 7baff7c080
90 changed files with 962 additions and 985 deletions
+9 -1
View File
@@ -2,11 +2,13 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using MQTTnet.Adapter;
using MQTTnet.Diagnostics;
using MQTTnet.Exceptions;
using MQTTnet.Formatter;
using MQTTnet.Internal;
using MQTTnet.Packets;
using MQTTnet.Protocol;
@@ -156,9 +158,11 @@ namespace MQTTnet.Client
public Task PublishAsync(MqttApplicationMessage applicationMessage)
{
if (applicationMessage == null) throw new ArgumentNullException(nameof(applicationMessage));
ThrowIfNotConnected();
var publishPacket = applicationMessage.ToPublishPacket();
var publishPacket = _adapter.PacketFormatterAdapter.ConvertApplicationMessageToPublishPacket(applicationMessage);
switch (applicationMessage.QualityOfServiceLevel)
{
@@ -205,6 +209,9 @@ namespace MQTTnet.Client
WillMessage = willApplicationMessage
};
//connectPacket.RequestProblemInformationProperty = true;
//connectPacket.RequestResponseInformationProperty = true;
var response = await SendAndReceiveAsync<MqttConnAckPacket>(connectPacket, cancellationToken).ConfigureAwait(false);
if (response.ConnectReturnCode != MqttConnectReturnCode.ConnectionAccepted)
{
@@ -516,6 +523,7 @@ namespace MQTTnet.Client
{
try
{
// TODO: Move conversion to formatter.
var applicationMessage = publishPacket.ToApplicationMessage();
ApplicationMessageReceived?.Invoke(this, new MqttApplicationMessageReceivedEventArgs(_options.ClientId, applicationMessage));
}