Add support for retained application messages

This commit is contained in:
Christian Kratky
2017-09-30 18:42:41 +02:00
parent 3cce33415d
commit 862f76fea2
24 changed files with 454 additions and 235 deletions
+3 -3
View File
@@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using MQTTnet.Core.Server;
namespace MQTTnet.Core.Adapter
@@ -7,8 +8,7 @@ namespace MQTTnet.Core.Adapter
{
event EventHandler<MqttClientConnectedEventArgs> ClientConnected;
void Start(MqttServerOptions options);
void Stop();
Task StartAsync(MqttServerOptions options);
Task StopAsync();
}
}
@@ -36,6 +36,10 @@ namespace MQTTnet.Core.Adapter
{
throw;
}
catch (OperationCanceledException)
{
throw;
}
catch (MqttCommunicationTimedOutException)
{
throw;
@@ -60,6 +64,10 @@ namespace MQTTnet.Core.Adapter
{
throw;
}
catch (OperationCanceledException)
{
throw;
}
catch (MqttCommunicationTimedOutException)
{
throw;
@@ -87,7 +95,7 @@ namespace MQTTnet.Core.Adapter
continue;
}
MqttTrace.Information(nameof(MqttChannelCommunicationAdapter), $"TX >>> {0} [Timeout={1}]", packet, timeout);
MqttTrace.Information(nameof(MqttChannelCommunicationAdapter), "TX >>> {0} [Timeout={1}]", packet, timeout);
var writeBuffer = PacketSerializer.Serialize(packet);
await _channel.SendStream.WriteAsync(writeBuffer, 0, writeBuffer.Length, cancellationToken).ConfigureAwait(false);
@@ -106,6 +114,10 @@ namespace MQTTnet.Core.Adapter
{
throw;
}
catch (OperationCanceledException)
{
throw;
}
catch (MqttCommunicationTimedOutException)
{
throw;
@@ -156,6 +168,10 @@ namespace MQTTnet.Core.Adapter
{
throw;
}
catch (OperationCanceledException)
{
throw;
}
catch (MqttCommunicationTimedOutException)
{
throw;
@@ -0,0 +1,17 @@
using System;
namespace MQTTnet.Core.Adapter
{
public class MqttClientDisconnectedEventArgs : EventArgs
{
public MqttClientDisconnectedEventArgs(string identifier, IMqttCommunicationAdapter clientAdapter)
{
Identifier = identifier ?? throw new ArgumentNullException(nameof(identifier));
ClientAdapter = clientAdapter ?? throw new ArgumentNullException(nameof(clientAdapter));
}
public string Identifier { get; }
public IMqttCommunicationAdapter ClientAdapter { get; }
}
}