Merge branch 'develop' of https://github.com/chkr1011/MQTTnet into develop

# Conflicts:
#	Frameworks/MQTTnet.NetStandard/Server/MqttClientPendingMessagesQueue.cs
#	Frameworks/MQTTnet.NetStandard/Server/MqttClientSessionsManager.cs
#	Frameworks/MQTTnet.NetStandard/Server/MqttRetainedMessagesManager.cs
This commit is contained in:
Sébastien Warin
2018-05-16 10:09:10 +02:00
29 changed files with 356 additions and 325 deletions
@@ -13,12 +13,12 @@ namespace MQTTnet.Server
{
public sealed class MqttClientPendingMessagesQueue : IDisposable
{
private readonly ConcurrentQueue<MqttBasePacket> _queue = new ConcurrentQueue<MqttBasePacket>();
private readonly AsyncAutoResetEvent _queueAutoResetEvent = new AsyncAutoResetEvent();
private readonly IMqttServerOptions _options;
private readonly MqttClientSession _clientSession;
private readonly IMqttNetChildLogger _logger;
private ConcurrentQueue<MqttBasePacket> _queue = new ConcurrentQueue<MqttBasePacket>();
private Task _workerTask;
public MqttClientPendingMessagesQueue(IMqttServerOptions options, MqttClientSession clientSession, IMqttNetChildLogger logger)
@@ -43,15 +43,7 @@ namespace MQTTnet.Server
_workerTask = Task.Run(() => SendQueuedPacketsAsync(adapter, cancellationToken), cancellationToken);
}
public void WaitForCompletion()
{
if (_workerTask != null)
{
Task.WaitAll(_workerTask);
}
}
public void Enqueue(MqttBasePacket packet)
{
if (packet == null) throw new ArgumentNullException(nameof(packet));
@@ -75,6 +67,17 @@ namespace MQTTnet.Server
_logger.Verbose("Enqueued packet (ClientId: {0}).", _clientSession.ClientId);
}
public void Clear()
{
var newQueue = new ConcurrentQueue<MqttBasePacket>();
Interlocked.Exchange(ref _queue, newQueue);
}
public void Dispose()
{
}
private async Task SendQueuedPacketsAsync(IMqttChannelAdapter adapter, CancellationToken cancellationToken)
{
try
@@ -151,9 +154,5 @@ namespace MQTTnet.Server
}
}
}
public void Dispose()
{
}
}
}