Migrate to Stream-less approach.

This commit is contained in:
Christian
2018-04-17 22:29:23 +02:00
parent ae11e31048
commit 17b74f20c9
22 changed files with 260 additions and 332 deletions
@@ -60,7 +60,7 @@ namespace MQTTnet.Client
_adapter = _adapterFactory.CreateClientAdapter(options, _logger);
_logger.Verbose<MqttClient>("Trying to connect with server.");
await _adapter.ConnectAsync(_options.CommunicationTimeout).ConfigureAwait(false);
await _adapter.ConnectAsync(_options.CommunicationTimeout, _cancellationTokenSource.Token).ConfigureAwait(false);
_logger.Verbose<MqttClient>("Connection with server established.");
await StartReceivingPacketsAsync().ConfigureAwait(false);
@@ -92,14 +92,9 @@ namespace MQTTnet.Client
public async Task DisconnectAsync()
{
if (!IsConnected)
{
return;
}
try
{
if (!_cancellationTokenSource.IsCancellationRequested)
if (IsConnected && !_cancellationTokenSource.IsCancellationRequested)
{
await SendAsync(new MqttDisconnectPacket()).ConfigureAwait(false);
}
@@ -6,7 +6,7 @@
public int? Port { get; set; }
public int BufferSize { get; set; } = 20 * 4096;
public int BufferSize { get; set; } = 4096;
public MqttClientTlsOptions TlsOptions { get; set; } = new MqttClientTlsOptions();
}