mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-26 16:24:10 +08:00
Remove _WithoutAutoReconnect_ from managed client.
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
* [Core] Added support for TLS 1.3 (requires .NET Core 3.1+) (thanks to @Dvergatal).
|
* [Core] Added support for TLS 1.3 (requires .NET Core 3.1+) (thanks to @Dvergatal).
|
||||||
* [Core] Added support for _MaximumQoS_ transmit when using MQTTv5 (thanks to @nayato).
|
* [Core] Added support for _MaximumQoS_ transmit when using MQTTv5 (thanks to @nayato).
|
||||||
* [Core] Aligned the format of some log messages.
|
* [Core] Aligned the format of some log messages.
|
||||||
|
* [ManagedClient] Removed _AutoReconnect_ since this does no longer work (BREAKING CHANGE!).
|
||||||
* [RpcClient] Moved the RPC topic validation to the topic generation strategy.
|
* [RpcClient] Moved the RPC topic validation to the topic generation strategy.
|
||||||
* [RcpClient] Added interface for _MqttRpcClient_.
|
* [RcpClient] Added interface for _MqttRpcClient_.
|
||||||
* [Server] Reduced async tasks count by moving dedicated keep alive tasks per connection to shared one.
|
* [Server] Reduced async tasks count by moving dedicated keep alive tasks per connection to shared one.
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ namespace MQTTnet.Extensions.ManagedClient
|
|||||||
{
|
{
|
||||||
IMqttClientOptions ClientOptions { get; }
|
IMqttClientOptions ClientOptions { get; }
|
||||||
|
|
||||||
bool AutoReconnect { get; }
|
|
||||||
|
|
||||||
TimeSpan AutoReconnectDelay { get; }
|
TimeSpan AutoReconnectDelay { get; }
|
||||||
|
|
||||||
TimeSpan ConnectionCheckInterval { get; }
|
TimeSpan ConnectionCheckInterval { get; }
|
||||||
|
|||||||
@@ -99,9 +99,9 @@ namespace MQTTnet.Extensions.ManagedClient
|
|||||||
|
|
||||||
Options = options;
|
Options = options;
|
||||||
|
|
||||||
if (Options.Storage != null)
|
if (options.Storage != null)
|
||||||
{
|
{
|
||||||
_storageManager = new ManagedMqttClientStorageManager(Options.Storage);
|
_storageManager = new ManagedMqttClientStorageManager(options.Storage);
|
||||||
var messages = await _storageManager.LoadQueuedMessagesAsync().ConfigureAwait(false);
|
var messages = await _storageManager.LoadQueuedMessagesAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
foreach (var message in messages)
|
foreach (var message in messages)
|
||||||
@@ -110,16 +110,13 @@ namespace MQTTnet.Extensions.ManagedClient
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Options.AutoReconnect)
|
var cancellationTokenSource = new CancellationTokenSource();
|
||||||
{
|
var cancellationToken = cancellationTokenSource.Token;
|
||||||
var cancellationTokenSource = new CancellationTokenSource();
|
_connectionCancellationToken = cancellationTokenSource;
|
||||||
var cancellationToken = cancellationTokenSource.Token;
|
|
||||||
_connectionCancellationToken = cancellationTokenSource;
|
_maintainConnectionTask = Task.Run(() => MaintainConnectionAsync(cancellationToken), cancellationToken);
|
||||||
|
_maintainConnectionTask.RunInBackground(_logger);
|
||||||
|
|
||||||
_maintainConnectionTask = Task.Run(() => MaintainConnectionAsync(cancellationToken), cancellationToken);
|
|
||||||
_maintainConnectionTask.Forget(_logger);
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.Info("Started");
|
_logger.Info("Started");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -579,7 +576,7 @@ namespace MQTTnet.Extensions.ManagedClient
|
|||||||
var cancellationToken = cancellationTokenSource.Token;
|
var cancellationToken = cancellationTokenSource.Token;
|
||||||
_publishingCancellationToken = cancellationTokenSource;
|
_publishingCancellationToken = cancellationTokenSource;
|
||||||
|
|
||||||
Task.Run(() => PublishQueuedMessagesAsync(cancellationToken), cancellationToken).Forget(_logger);
|
Task.Run(() => PublishQueuedMessagesAsync(cancellationToken), cancellationToken).RunInBackground(_logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StopPublishing()
|
void StopPublishing()
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ namespace MQTTnet.Extensions.ManagedClient
|
|||||||
{
|
{
|
||||||
public IMqttClientOptions ClientOptions { get; set; }
|
public IMqttClientOptions ClientOptions { get; set; }
|
||||||
|
|
||||||
public bool AutoReconnect { get; set; } = true;
|
|
||||||
|
|
||||||
public TimeSpan AutoReconnectDelay { get; set; } = TimeSpan.FromSeconds(5);
|
public TimeSpan AutoReconnectDelay { get; set; } = TimeSpan.FromSeconds(5);
|
||||||
|
|
||||||
public TimeSpan ConnectionCheckInterval { get; set; } = TimeSpan.FromSeconds(1);
|
public TimeSpan ConnectionCheckInterval { get; set; } = TimeSpan.FromSeconds(1);
|
||||||
|
|||||||
@@ -68,18 +68,6 @@ namespace MQTTnet.Extensions.ManagedClient
|
|||||||
options(_clientOptionsBuilder);
|
options(_clientOptionsBuilder);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManagedMqttClientOptionsBuilder WithAutoReconnect()
|
|
||||||
{
|
|
||||||
_options.AutoReconnect = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ManagedMqttClientOptionsBuilder WithoutAutoReconnect()
|
|
||||||
{
|
|
||||||
_options.AutoReconnect = false;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ManagedMqttClientOptions Build()
|
public ManagedMqttClientOptions Build()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user