mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-20 03:24:33 +08:00
ManagedClient: Expose internal client.
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
<releaseNotes>
|
<releaseNotes>
|
||||||
* [Client] Fixed wrong value for "ClientWasConnected" in "MqttClientDisconnectedEventArgs" #976 (thanks to @dbeinder).
|
* [Client] Fixed wrong value for "ClientWasConnected" in "MqttClientDisconnectedEventArgs" #976 (thanks to @dbeinder).
|
||||||
* [Client] Added direct support for Amazon AWS connections (requires .NET Core 3.1) (thanks to @henning-krause).
|
* [Client] Added direct support for Amazon AWS connections (requires .NET Core 3.1) (thanks to @henning-krause).
|
||||||
|
* [ManagedClient] Exposed the internal MQTT client.
|
||||||
* [Server] Added client message queue interceptor for QoS level (tahnks to @msallin).
|
* [Server] Added client message queue interceptor for QoS level (tahnks to @msallin).
|
||||||
</releaseNotes>
|
</releaseNotes>
|
||||||
<copyright>Copyright Christian Kratky 2016-2020</copyright>
|
<copyright>Copyright Christian Kratky 2016-2020</copyright>
|
||||||
|
|||||||
@@ -4,30 +4,46 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MQTTnet.Client;
|
||||||
|
|
||||||
namespace MQTTnet.Extensions.ManagedClient
|
namespace MQTTnet.Extensions.ManagedClient
|
||||||
{
|
{
|
||||||
public interface IManagedMqttClient : IApplicationMessageReceiver, IApplicationMessagePublisher, IDisposable
|
public interface IManagedMqttClient : IApplicationMessageReceiver, IApplicationMessagePublisher, IDisposable
|
||||||
{
|
{
|
||||||
bool IsStarted { get; }
|
/// <summary>
|
||||||
bool IsConnected { get; }
|
/// Gets the internally used MQTT client.
|
||||||
int PendingApplicationMessagesCount { get; }
|
/// This property should be used with caution because manipulating the internal client might break the managed client.
|
||||||
IManagedMqttClientOptions Options { get; }
|
/// </summary>
|
||||||
|
IMqttClient InternalClient { get; }
|
||||||
|
|
||||||
|
bool IsStarted { get; }
|
||||||
|
|
||||||
|
bool IsConnected { get; }
|
||||||
|
|
||||||
|
int PendingApplicationMessagesCount { get; }
|
||||||
|
|
||||||
|
IManagedMqttClientOptions Options { get; }
|
||||||
|
|
||||||
IMqttClientConnectedHandler ConnectedHandler { get; set; }
|
IMqttClientConnectedHandler ConnectedHandler { get; set; }
|
||||||
|
|
||||||
IMqttClientDisconnectedHandler DisconnectedHandler { get; set; }
|
IMqttClientDisconnectedHandler DisconnectedHandler { get; set; }
|
||||||
|
|
||||||
IApplicationMessageProcessedHandler ApplicationMessageProcessedHandler { get; set; }
|
IApplicationMessageProcessedHandler ApplicationMessageProcessedHandler { get; set; }
|
||||||
|
|
||||||
IApplicationMessageSkippedHandler ApplicationMessageSkippedHandler { get; set; }
|
IApplicationMessageSkippedHandler ApplicationMessageSkippedHandler { get; set; }
|
||||||
|
|
||||||
IConnectingFailedHandler ConnectingFailedHandler { get; set; }
|
IConnectingFailedHandler ConnectingFailedHandler { get; set; }
|
||||||
|
|
||||||
ISynchronizingSubscriptionsFailedHandler SynchronizingSubscriptionsFailedHandler { get; set; }
|
ISynchronizingSubscriptionsFailedHandler SynchronizingSubscriptionsFailedHandler { get; set; }
|
||||||
|
|
||||||
Task StartAsync(IManagedMqttClientOptions options);
|
Task StartAsync(IManagedMqttClientOptions options);
|
||||||
|
|
||||||
Task StopAsync();
|
Task StopAsync();
|
||||||
|
|
||||||
Task PingAsync(CancellationToken cancellationToken);
|
Task PingAsync(CancellationToken cancellationToken);
|
||||||
|
|
||||||
Task SubscribeAsync(IEnumerable<MqttTopicFilter> topicFilters);
|
Task SubscribeAsync(IEnumerable<MqttTopicFilter> topicFilters);
|
||||||
|
|
||||||
Task UnsubscribeAsync(IEnumerable<string> topics);
|
Task UnsubscribeAsync(IEnumerable<string> topics);
|
||||||
|
|
||||||
Task PublishAsync(ManagedMqttApplicationMessage applicationMessages);
|
Task PublishAsync(ManagedMqttApplicationMessage applicationMessages);
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ namespace MQTTnet.Extensions.ManagedClient
|
|||||||
public ManagedMqttClient(IMqttClient mqttClient, IMqttNetLogger logger)
|
public ManagedMqttClient(IMqttClient mqttClient, IMqttNetLogger logger)
|
||||||
{
|
{
|
||||||
_mqttClient = mqttClient ?? throw new ArgumentNullException(nameof(mqttClient));
|
_mqttClient = mqttClient ?? throw new ArgumentNullException(nameof(mqttClient));
|
||||||
|
InternalClient = mqttClient;
|
||||||
|
|
||||||
if (logger == null) throw new ArgumentNullException(nameof(logger));
|
if (logger == null) throw new ArgumentNullException(nameof(logger));
|
||||||
_logger = logger.CreateScopedLogger(nameof(ManagedMqttClient));
|
_logger = logger.CreateScopedLogger(nameof(ManagedMqttClient));
|
||||||
@@ -55,6 +56,8 @@ namespace MQTTnet.Extensions.ManagedClient
|
|||||||
|
|
||||||
public bool IsStarted => _connectionCancellationToken != null;
|
public bool IsStarted => _connectionCancellationToken != null;
|
||||||
|
|
||||||
|
public IMqttClient InternalClient { get; }
|
||||||
|
|
||||||
public int PendingApplicationMessagesCount => _messageQueue.Count;
|
public int PendingApplicationMessagesCount => _messageQueue.Count;
|
||||||
|
|
||||||
public IManagedMqttClientOptions Options { get; private set; }
|
public IManagedMqttClientOptions Options { get; private set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user