mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-11-02 12:12:38 +08:00
Merge branch 'master' of https://github.com/chkr1011/MQTTnet into feature/Reason_Code_In_Subscription_Interceptor
# Conflicts: # Build/MQTTnet.nuspec # Source/MQTTnet/Server/Internal/MqttClientSessionsManager.cs
This commit is contained in:
@@ -1,15 +1,16 @@
|
|||||||
using MQTTnet.Adapter;
|
using MQTTnet.Adapter;
|
||||||
using MQTTnet.AspNetCore.Client.Tcp;
|
using MQTTnet.AspNetCore.Client.Tcp;
|
||||||
using MQTTnet.Client.Options;
|
|
||||||
using MQTTnet.Formatter;
|
using MQTTnet.Formatter;
|
||||||
using System;
|
using System;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using MQTTnet.Client;
|
||||||
|
using MQTTnet.Diagnostics;
|
||||||
|
|
||||||
namespace MQTTnet.AspNetCore.Client
|
namespace MQTTnet.AspNetCore.Client
|
||||||
{
|
{
|
||||||
public class MqttClientConnectionContextFactory : IMqttClientAdapterFactory
|
public class MqttClientConnectionContextFactory : IMqttClientAdapterFactory
|
||||||
{
|
{
|
||||||
public IMqttChannelAdapter CreateClientAdapter(IMqttClientOptions options)
|
public IMqttChannelAdapter CreateClientAdapter(IMqttClientOptions options, IMqttNetLogger logger)
|
||||||
{
|
{
|
||||||
if (options == null) throw new ArgumentNullException(nameof(options));
|
if (options == null) throw new ArgumentNullException(nameof(options));
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using MQTTnet.Adapter;
|
using MQTTnet.Adapter;
|
||||||
using MQTTnet.Diagnostics;
|
using MQTTnet.Diagnostics;
|
||||||
using MQTTnet.Diagnostics.Logger;
|
|
||||||
using MQTTnet.Implementations;
|
using MQTTnet.Implementations;
|
||||||
using MQTTnet.Server;
|
using MQTTnet.Server;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using MQTTnet.Adapter;
|
|||||||
using MQTTnet.Server;
|
using MQTTnet.Server;
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MQTTnet.Diagnostics;
|
||||||
using MQTTnet.Formatter;
|
using MQTTnet.Formatter;
|
||||||
|
|
||||||
namespace MQTTnet.AspNetCore
|
namespace MQTTnet.AspNetCore
|
||||||
@@ -33,7 +34,7 @@ namespace MQTTnet.AspNetCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task StartAsync(MqttServerOptions options)
|
public Task StartAsync(MqttServerOptions options, IMqttNetLogger logger)
|
||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using MQTTnet.Adapter;
|
using MQTTnet.Adapter;
|
||||||
using MQTTnet.Diagnostics.Logger;
|
using MQTTnet.Diagnostics;
|
||||||
using MQTTnet.Server;
|
using MQTTnet.Server;
|
||||||
|
|
||||||
namespace MQTTnet.AspNetCore
|
namespace MQTTnet.AspNetCore
|
||||||
|
|||||||
@@ -6,23 +6,19 @@ using MQTTnet.Server;
|
|||||||
using System;
|
using System;
|
||||||
using System.Net.WebSockets;
|
using System.Net.WebSockets;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MQTTnet.Diagnostics.Logger;
|
using MQTTnet.Diagnostics;
|
||||||
|
|
||||||
namespace MQTTnet.AspNetCore
|
namespace MQTTnet.AspNetCore
|
||||||
{
|
{
|
||||||
public sealed class MqttWebSocketServerAdapter : IMqttServerAdapter
|
public sealed class MqttWebSocketServerAdapter : IMqttServerAdapter
|
||||||
{
|
{
|
||||||
readonly IMqttNetLogger _rootLogger;
|
IMqttNetLogger _logger = new MqttNetNullLogger();
|
||||||
|
|
||||||
public MqttWebSocketServerAdapter(IMqttNetLogger logger)
|
|
||||||
{
|
|
||||||
_rootLogger = logger ?? throw new ArgumentNullException(nameof(logger));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Func<IMqttChannelAdapter, Task> ClientHandler { get; set; }
|
public Func<IMqttChannelAdapter, Task> ClientHandler { get; set; }
|
||||||
|
|
||||||
public Task StartAsync(MqttServerOptions options)
|
public Task StartAsync(MqttServerOptions options, IMqttNetLogger logger)
|
||||||
{
|
{
|
||||||
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +45,7 @@ namespace MQTTnet.AspNetCore
|
|||||||
var formatter = new MqttPacketFormatterAdapter(writer);
|
var formatter = new MqttPacketFormatterAdapter(writer);
|
||||||
var channel = new MqttWebSocketChannel(webSocket, endpoint, isSecureConnection, clientCertificate);
|
var channel = new MqttWebSocketChannel(webSocket, endpoint, isSecureConnection, clientCertificate);
|
||||||
|
|
||||||
using (var channelAdapter = new MqttChannelAdapter(channel, formatter, null, _rootLogger))
|
using (var channelAdapter = new MqttChannelAdapter(channel, formatter, null, _logger))
|
||||||
{
|
{
|
||||||
await clientHandler(channelAdapter).ConfigureAwait(false);
|
await clientHandler(channelAdapter).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
using MQTTnet.Client.Connecting;
|
using System;
|
||||||
using MQTTnet.Client.Disconnecting;
|
|
||||||
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;
|
using MQTTnet.Client;
|
||||||
|
using MQTTnet.Packets;
|
||||||
|
|
||||||
namespace MQTTnet.Extensions.ManagedClient
|
namespace MQTTnet.Extensions.ManagedClient
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using MQTTnet.Client.Options;
|
using MQTTnet.Client;
|
||||||
using MQTTnet.Server;
|
using MQTTnet.Server;
|
||||||
|
|
||||||
namespace MQTTnet.Extensions.ManagedClient
|
namespace MQTTnet.Extensions.ManagedClient
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
using MQTTnet.Client;
|
using MQTTnet.Client;
|
||||||
using MQTTnet.Client.Connecting;
|
|
||||||
using MQTTnet.Client.Disconnecting;
|
|
||||||
using MQTTnet.Client.Publishing;
|
|
||||||
using MQTTnet.Client.Receiving;
|
|
||||||
using MQTTnet.Diagnostics;
|
|
||||||
using MQTTnet.Exceptions;
|
using MQTTnet.Exceptions;
|
||||||
using MQTTnet.Internal;
|
using MQTTnet.Internal;
|
||||||
using MQTTnet.Protocol;
|
using MQTTnet.Protocol;
|
||||||
@@ -13,7 +8,8 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MQTTnet.Diagnostics.Logger;
|
using MQTTnet.Diagnostics;
|
||||||
|
using MQTTnet.Packets;
|
||||||
|
|
||||||
namespace MQTTnet.Extensions.ManagedClient
|
namespace MQTTnet.Extensions.ManagedClient
|
||||||
{
|
{
|
||||||
@@ -72,13 +68,7 @@ namespace MQTTnet.Extensions.ManagedClient
|
|||||||
get => InternalClient.DisconnectedHandler;
|
get => InternalClient.DisconnectedHandler;
|
||||||
set => InternalClient.DisconnectedHandler = value;
|
set => InternalClient.DisconnectedHandler = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMqttApplicationMessageReceivedHandler ApplicationMessageReceivedHandler
|
|
||||||
{
|
|
||||||
get => InternalClient.ApplicationMessageReceivedHandler;
|
|
||||||
set => InternalClient.ApplicationMessageReceivedHandler = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public event Func<MqttApplicationMessageReceivedEventArgs, Task> ApplicationMessageReceivedAsync
|
public event Func<MqttApplicationMessageReceivedEventArgs, Task> ApplicationMessageReceivedAsync
|
||||||
{
|
{
|
||||||
add => InternalClient.ApplicationMessageReceivedAsync += value;
|
add => InternalClient.ApplicationMessageReceivedAsync += value;
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
using MQTTnet.Client.Connecting;
|
using MQTTnet.Protocol;
|
||||||
using MQTTnet.Client.Disconnecting;
|
|
||||||
using MQTTnet.Client.Publishing;
|
|
||||||
using MQTTnet.Client.Receiving;
|
|
||||||
using MQTTnet.Protocol;
|
|
||||||
using System;
|
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;
|
||||||
|
using MQTTnet.Packets;
|
||||||
|
|
||||||
namespace MQTTnet.Extensions.ManagedClient
|
namespace MQTTnet.Extensions.ManagedClient
|
||||||
{
|
{
|
||||||
@@ -75,42 +73,7 @@ namespace MQTTnet.Extensions.ManagedClient
|
|||||||
client.DisconnectedHandler = handler;
|
client.DisconnectedHandler = handler;
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TReceiver UseApplicationMessageReceivedHandler<TReceiver>(this TReceiver receiver, Func<MqttApplicationMessageReceivedEventArgs, Task> handler)
|
|
||||||
where TReceiver : IMqttApplicationMessageReceiver
|
|
||||||
{
|
|
||||||
if (receiver == null) throw new ArgumentNullException(nameof(receiver));
|
|
||||||
|
|
||||||
if (handler == null)
|
|
||||||
{
|
|
||||||
return receiver.UseApplicationMessageReceivedHandler((IMqttApplicationMessageReceivedHandler)null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return receiver.UseApplicationMessageReceivedHandler(new MqttApplicationMessageReceivedHandlerDelegate(handler));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TReceiver UseApplicationMessageReceivedHandler<TReceiver>(this TReceiver receiver, Action<MqttApplicationMessageReceivedEventArgs> handler)
|
|
||||||
where TReceiver : IMqttApplicationMessageReceiver
|
|
||||||
{
|
|
||||||
if (receiver == null) throw new ArgumentNullException(nameof(receiver));
|
|
||||||
|
|
||||||
if (handler == null)
|
|
||||||
{
|
|
||||||
return receiver.UseApplicationMessageReceivedHandler((IMqttApplicationMessageReceivedHandler)null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return receiver.UseApplicationMessageReceivedHandler(new MqttApplicationMessageReceivedHandlerDelegate(handler));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TReceiver UseApplicationMessageReceivedHandler<TReceiver>(this TReceiver receiver, IMqttApplicationMessageReceivedHandler handler)
|
|
||||||
where TReceiver : IMqttApplicationMessageReceiver
|
|
||||||
{
|
|
||||||
if (receiver == null) throw new ArgumentNullException(nameof(receiver));
|
|
||||||
|
|
||||||
receiver.ApplicationMessageReceivedHandler = handler;
|
|
||||||
return receiver;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Task SubscribeAsync(this IManagedMqttClient client, params MqttTopicFilter[] topicFilters)
|
public static Task SubscribeAsync(this IManagedMqttClient client, params MqttTopicFilter[] topicFilters)
|
||||||
{
|
{
|
||||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using MQTTnet.Client.Options;
|
using MQTTnet.Client;
|
||||||
using MQTTnet.Server;
|
using MQTTnet.Server;
|
||||||
|
|
||||||
namespace MQTTnet.Extensions.ManagedClient
|
namespace MQTTnet.Extensions.ManagedClient
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using MQTTnet.Client.Options;
|
using MQTTnet.Client;
|
||||||
using MQTTnet.Server;
|
using MQTTnet.Server;
|
||||||
|
|
||||||
namespace MQTTnet.Extensions.ManagedClient
|
namespace MQTTnet.Extensions.ManagedClient
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using MQTTnet.Diagnostics.Logger;
|
using MQTTnet.Diagnostics;
|
||||||
|
|
||||||
namespace MQTTnet.Extensions.ManagedClient
|
namespace MQTTnet.Extensions.ManagedClient
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using System;
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MQTTnet.Client.Subscribing;
|
|
||||||
using MQTTnet.Implementations;
|
using MQTTnet.Implementations;
|
||||||
|
|
||||||
namespace MQTTnet.Extensions.Rpc
|
namespace MQTTnet.Extensions.Rpc
|
||||||
@@ -17,23 +16,13 @@ namespace MQTTnet.Extensions.Rpc
|
|||||||
readonly ConcurrentDictionary<string, TaskCompletionSource<byte[]>> _waitingCalls = new ConcurrentDictionary<string, TaskCompletionSource<byte[]>>();
|
readonly ConcurrentDictionary<string, TaskCompletionSource<byte[]>> _waitingCalls = new ConcurrentDictionary<string, TaskCompletionSource<byte[]>>();
|
||||||
readonly IMqttClient _mqttClient;
|
readonly IMqttClient _mqttClient;
|
||||||
readonly IMqttRpcClientOptions _options;
|
readonly IMqttRpcClientOptions _options;
|
||||||
readonly RpcAwareApplicationMessageReceivedHandler _applicationMessageReceivedHandler;
|
|
||||||
|
|
||||||
[Obsolete("Use MqttRpcClient(IMqttClient mqttClient, IMqttRpcClientOptions options).")]
|
|
||||||
public MqttRpcClient(IMqttClient mqttClient) : this(mqttClient, new MqttRpcClientOptions())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public MqttRpcClient(IMqttClient mqttClient, IMqttRpcClientOptions options)
|
public MqttRpcClient(IMqttClient mqttClient, IMqttRpcClientOptions options)
|
||||||
{
|
{
|
||||||
_mqttClient = mqttClient ?? throw new ArgumentNullException(nameof(mqttClient));
|
_mqttClient = mqttClient ?? throw new ArgumentNullException(nameof(mqttClient));
|
||||||
_options = options ?? throw new ArgumentNullException(nameof(options));
|
_options = options ?? throw new ArgumentNullException(nameof(options));
|
||||||
|
|
||||||
_applicationMessageReceivedHandler = new RpcAwareApplicationMessageReceivedHandler(
|
_mqttClient.ApplicationMessageReceivedAsync += HandleApplicationMessageReceivedAsync;
|
||||||
mqttClient.ApplicationMessageReceivedHandler,
|
|
||||||
HandleApplicationMessageReceivedAsync);
|
|
||||||
|
|
||||||
_mqttClient.ApplicationMessageReceivedHandler = _applicationMessageReceivedHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<byte[]> ExecuteAsync(TimeSpan timeout, string methodName, byte[] payload, MqttQualityOfServiceLevel qualityOfServiceLevel)
|
public async Task<byte[]> ExecuteAsync(TimeSpan timeout, string methodName, byte[] payload, MqttQualityOfServiceLevel qualityOfServiceLevel)
|
||||||
@@ -59,12 +48,7 @@ namespace MQTTnet.Extensions.Rpc
|
|||||||
public async Task<byte[]> ExecuteAsync(string methodName, byte[] payload, MqttQualityOfServiceLevel qualityOfServiceLevel, CancellationToken cancellationToken)
|
public async Task<byte[]> ExecuteAsync(string methodName, byte[] payload, MqttQualityOfServiceLevel qualityOfServiceLevel, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (methodName == null) throw new ArgumentNullException(nameof(methodName));
|
if (methodName == null) throw new ArgumentNullException(nameof(methodName));
|
||||||
|
|
||||||
if (!(_mqttClient.ApplicationMessageReceivedHandler is RpcAwareApplicationMessageReceivedHandler))
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("The application message received handler was modified.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var topicNames = _options.TopicGenerationStrategy.CreateRpcTopics(new TopicGenerationContext
|
var topicNames = _options.TopicGenerationStrategy.CreateRpcTopics(new TopicGenerationContext
|
||||||
{
|
{
|
||||||
MethodName = methodName,
|
MethodName = methodName,
|
||||||
@@ -146,7 +130,7 @@ namespace MQTTnet.Extensions.Rpc
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_mqttClient.ApplicationMessageReceivedHandler = _applicationMessageReceivedHandler.OriginalHandler;
|
_mqttClient.ApplicationMessageReceivedAsync -= HandleApplicationMessageReceivedAsync;
|
||||||
|
|
||||||
foreach (var tcs in _waitingCalls)
|
foreach (var tcs in _waitingCalls)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using MQTTnet.Client.Receiving;
|
|
||||||
|
|
||||||
namespace MQTTnet.Extensions.Rpc
|
|
||||||
{
|
|
||||||
public sealed class RpcAwareApplicationMessageReceivedHandler : IMqttApplicationMessageReceivedHandler
|
|
||||||
{
|
|
||||||
readonly Func<MqttApplicationMessageReceivedEventArgs, Task> _handleReceivedApplicationMessageAsync;
|
|
||||||
|
|
||||||
public RpcAwareApplicationMessageReceivedHandler(
|
|
||||||
IMqttApplicationMessageReceivedHandler originalHandler,
|
|
||||||
Func<MqttApplicationMessageReceivedEventArgs, Task> handleReceivedApplicationMessageAsync)
|
|
||||||
{
|
|
||||||
OriginalHandler = originalHandler;
|
|
||||||
_handleReceivedApplicationMessageAsync = handleReceivedApplicationMessageAsync ?? throw new ArgumentNullException(nameof(handleReceivedApplicationMessageAsync));
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMqttApplicationMessageReceivedHandler OriginalHandler { get; }
|
|
||||||
|
|
||||||
public async Task HandleApplicationMessageReceivedAsync(MqttApplicationMessageReceivedEventArgs eventArgs)
|
|
||||||
{
|
|
||||||
// First try to check if there is a pending RPC call!
|
|
||||||
await _handleReceivedApplicationMessageAsync(eventArgs).ConfigureAwait(false);
|
|
||||||
|
|
||||||
if (OriginalHandler != null)
|
|
||||||
{
|
|
||||||
await OriginalHandler.HandleApplicationMessageReceivedAsync(eventArgs).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,7 @@ namespace MQTTnet.Extensions.WebSocket4Net
|
|||||||
{
|
{
|
||||||
if (mqttFactory == null) throw new ArgumentNullException(nameof(mqttFactory));
|
if (mqttFactory == null) throw new ArgumentNullException(nameof(mqttFactory));
|
||||||
|
|
||||||
return mqttFactory.UseClientAdapterFactory(new WebSocket4NetMqttClientAdapterFactory(mqttFactory.DefaultLogger));
|
return mqttFactory.UseClientAdapterFactory(new WebSocket4NetMqttClientAdapterFactory());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,8 @@ using System.Security.Cryptography.X509Certificates;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MQTTnet.Channel;
|
using MQTTnet.Channel;
|
||||||
using MQTTnet.Client.Options;
|
using MQTTnet.Client;
|
||||||
using MQTTnet.Exceptions;
|
using MQTTnet.Exceptions;
|
||||||
using MQTTnet.Internal;
|
|
||||||
using SuperSocket.ClientEngine;
|
using SuperSocket.ClientEngine;
|
||||||
using WebSocket4Net;
|
using WebSocket4Net;
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,15 @@
|
|||||||
using MQTTnet.Adapter;
|
using MQTTnet.Adapter;
|
||||||
using MQTTnet.Client.Options;
|
|
||||||
using MQTTnet.Diagnostics;
|
|
||||||
using MQTTnet.Formatter;
|
using MQTTnet.Formatter;
|
||||||
using MQTTnet.Implementations;
|
using MQTTnet.Implementations;
|
||||||
using System;
|
using System;
|
||||||
using MQTTnet.Diagnostics.Logger;
|
using MQTTnet.Client;
|
||||||
|
using MQTTnet.Diagnostics;
|
||||||
|
|
||||||
namespace MQTTnet.Extensions.WebSocket4Net
|
namespace MQTTnet.Extensions.WebSocket4Net
|
||||||
{
|
{
|
||||||
public sealed class WebSocket4NetMqttClientAdapterFactory : IMqttClientAdapterFactory
|
public sealed class WebSocket4NetMqttClientAdapterFactory : IMqttClientAdapterFactory
|
||||||
{
|
{
|
||||||
readonly IMqttNetLogger _logger;
|
public IMqttChannelAdapter CreateClientAdapter(IMqttClientOptions options, IMqttNetLogger logger)
|
||||||
|
|
||||||
public WebSocket4NetMqttClientAdapterFactory(IMqttNetLogger logger)
|
|
||||||
{
|
|
||||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMqttChannelAdapter CreateClientAdapter(IMqttClientOptions options)
|
|
||||||
{
|
{
|
||||||
if (options == null) throw new ArgumentNullException(nameof(options));
|
if (options == null) throw new ArgumentNullException(nameof(options));
|
||||||
|
|
||||||
@@ -29,7 +21,7 @@ namespace MQTTnet.Extensions.WebSocket4Net
|
|||||||
new MqttTcpChannel(options),
|
new MqttTcpChannel(options),
|
||||||
new MqttPacketFormatterAdapter(options.ProtocolVersion),
|
new MqttPacketFormatterAdapter(options.ProtocolVersion),
|
||||||
options.PacketInspector,
|
options.PacketInspector,
|
||||||
_logger);
|
logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
case MqttClientWebSocketOptions webSocketOptions:
|
case MqttClientWebSocketOptions webSocketOptions:
|
||||||
@@ -38,7 +30,7 @@ namespace MQTTnet.Extensions.WebSocket4Net
|
|||||||
new WebSocket4NetMqttChannel(options, webSocketOptions),
|
new WebSocket4NetMqttChannel(options, webSocketOptions),
|
||||||
new MqttPacketFormatterAdapter(options.ProtocolVersion),
|
new MqttPacketFormatterAdapter(options.ProtocolVersion),
|
||||||
options.PacketInspector,
|
options.PacketInspector,
|
||||||
_logger);
|
logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
using MQTTnet.Client.Options;
|
using MQTTnet.Client;
|
||||||
|
using MQTTnet.Diagnostics;
|
||||||
|
|
||||||
namespace MQTTnet.Adapter
|
namespace MQTTnet.Adapter
|
||||||
{
|
{
|
||||||
public interface IMqttClientAdapterFactory
|
public interface IMqttClientAdapterFactory
|
||||||
{
|
{
|
||||||
IMqttChannelAdapter CreateClientAdapter(IMqttClientOptions options);
|
IMqttChannelAdapter CreateClientAdapter(IMqttClientOptions options, IMqttNetLogger logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MQTTnet.Diagnostics;
|
||||||
using MQTTnet.Server;
|
using MQTTnet.Server;
|
||||||
|
|
||||||
namespace MQTTnet.Adapter
|
namespace MQTTnet.Adapter
|
||||||
@@ -8,7 +9,7 @@ namespace MQTTnet.Adapter
|
|||||||
{
|
{
|
||||||
Func<IMqttChannelAdapter, Task> ClientHandler { get; set; }
|
Func<IMqttChannelAdapter, Task> ClientHandler { get; set; }
|
||||||
|
|
||||||
Task StartAsync(MqttServerOptions options);
|
Task StartAsync(MqttServerOptions options, IMqttNetLogger logger);
|
||||||
Task StopAsync();
|
Task StopAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ using System.Runtime.InteropServices;
|
|||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MQTTnet.Diagnostics.Logger;
|
|
||||||
using MQTTnet.Diagnostics.PacketInspection;
|
|
||||||
|
|
||||||
namespace MQTTnet.Adapter
|
namespace MQTTnet.Adapter
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using MQTTnet.Client.Connecting;
|
using MQTTnet.Client;
|
||||||
using MQTTnet.Exceptions;
|
using MQTTnet.Exceptions;
|
||||||
|
|
||||||
namespace MQTTnet.Adapter
|
namespace MQTTnet.Adapter
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using MQTTnet.Diagnostics;
|
using MQTTnet.Diagnostics;
|
||||||
using MQTTnet.Diagnostics.Logger;
|
|
||||||
using MQTTnet.Diagnostics.PacketInspection;
|
|
||||||
using MQTTnet.Formatter;
|
using MQTTnet.Formatter;
|
||||||
|
|
||||||
namespace MQTTnet.Adapter
|
namespace MQTTnet.Adapter
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Connecting
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public interface IMqttClientConnectedHandler
|
public interface IMqttClientConnectedHandler
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
using MQTTnet.Protocol;
|
using MQTTnet.Protocol;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Connecting
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public sealed class MqttClientConnectResult
|
public sealed class MqttClientConnectResult
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace MQTTnet.Client.Connecting
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public enum MqttClientConnectResultCode
|
public enum MqttClientConnectResultCode
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using MQTTnet.Formatter;
|
|||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
using MQTTnet.Protocol;
|
using MQTTnet.Protocol;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Connecting
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public sealed class MqttClientConnectResultFactory
|
public sealed class MqttClientConnectResultFactory
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Connecting
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public class MqttClientConnectedEventArgs : EventArgs
|
public class MqttClientConnectedEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Connecting
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public class MqttClientConnectedHandlerDelegate : IMqttClientConnectedHandler
|
public class MqttClientConnectedHandlerDelegate : IMqttClientConnectedHandler
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Disconnecting
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public interface IMqttClientDisconnectedHandler
|
public interface IMqttClientDisconnectedHandler
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace MQTTnet.Client.Disconnecting
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public sealed class MqttClientDisconnectOptions
|
public sealed class MqttClientDisconnectOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace MQTTnet.Client.Disconnecting
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public sealed class MqttClientDisconnectOptionsBuilder
|
public sealed class MqttClientDisconnectOptionsBuilder
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace MQTTnet.Client.Disconnecting
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public enum MqttClientDisconnectReason
|
public enum MqttClientDisconnectReason
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using MQTTnet.Client.Connecting;
|
|
||||||
|
|
||||||
namespace MQTTnet.Client.Disconnecting
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public sealed class MqttClientDisconnectedEventArgs : EventArgs
|
public sealed class MqttClientDisconnectedEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Disconnecting
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public class MqttClientDisconnectedHandlerDelegate : IMqttClientDisconnectedHandler
|
public class MqttClientDisconnectedHandlerDelegate : IMqttClientDisconnectedHandler
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MQTTnet.Client.ExtendedAuthenticationExchange
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public interface IMqttExtendedAuthenticationExchangeHandler
|
public interface IMqttExtendedAuthenticationExchangeHandler
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
using MQTTnet.Protocol;
|
using MQTTnet.Protocol;
|
||||||
|
|
||||||
namespace MQTTnet.Client.ExtendedAuthenticationExchange
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public class MqttExtendedAuthenticationExchangeContext
|
public class MqttExtendedAuthenticationExchangeContext
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
using MQTTnet.Protocol;
|
using MQTTnet.Protocol;
|
||||||
|
|
||||||
namespace MQTTnet.Client.ExtendedAuthenticationExchange
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public class MqttExtendedAuthenticationExchangeData
|
public class MqttExtendedAuthenticationExchangeData
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
using MQTTnet.Client.Connecting;
|
using System;
|
||||||
using MQTTnet.Client.Disconnecting;
|
|
||||||
using MQTTnet.Client.ExtendedAuthenticationExchange;
|
|
||||||
using MQTTnet.Client.Options;
|
|
||||||
using MQTTnet.Client.Subscribing;
|
|
||||||
using MQTTnet.Client.Unsubscribing;
|
|
||||||
using System;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,4 @@
|
|||||||
using MQTTnet.Adapter;
|
using MQTTnet.Adapter;
|
||||||
using MQTTnet.Client.Connecting;
|
|
||||||
using MQTTnet.Client.Disconnecting;
|
|
||||||
using MQTTnet.Client.ExtendedAuthenticationExchange;
|
|
||||||
using MQTTnet.Client.Options;
|
|
||||||
using MQTTnet.Client.Publishing;
|
|
||||||
using MQTTnet.Client.Receiving;
|
|
||||||
using MQTTnet.Client.Subscribing;
|
|
||||||
using MQTTnet.Client.Unsubscribing;
|
|
||||||
using MQTTnet.Exceptions;
|
using MQTTnet.Exceptions;
|
||||||
using MQTTnet.Internal;
|
using MQTTnet.Internal;
|
||||||
using MQTTnet.PacketDispatcher;
|
using MQTTnet.PacketDispatcher;
|
||||||
@@ -15,7 +7,7 @@ using MQTTnet.Protocol;
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MQTTnet.Diagnostics.Logger;
|
using MQTTnet.Diagnostics;
|
||||||
using MQTTnet.Formatter;
|
using MQTTnet.Formatter;
|
||||||
using MQTTnet.Implementations;
|
using MQTTnet.Implementations;
|
||||||
|
|
||||||
@@ -33,6 +25,7 @@ namespace MQTTnet.Client
|
|||||||
readonly AsyncEvent<MqttApplicationMessageReceivedEventArgs> _applicationMessageReceivedEvent = new AsyncEvent<MqttApplicationMessageReceivedEventArgs>();
|
readonly AsyncEvent<MqttApplicationMessageReceivedEventArgs> _applicationMessageReceivedEvent = new AsyncEvent<MqttApplicationMessageReceivedEventArgs>();
|
||||||
|
|
||||||
readonly IMqttClientAdapterFactory _adapterFactory;
|
readonly IMqttClientAdapterFactory _adapterFactory;
|
||||||
|
readonly IMqttNetLogger _rootLogger;
|
||||||
readonly MqttNetSourceLogger _logger;
|
readonly MqttNetSourceLogger _logger;
|
||||||
|
|
||||||
CancellationTokenSource _backgroundCancellationTokenSource;
|
CancellationTokenSource _backgroundCancellationTokenSource;
|
||||||
@@ -49,12 +42,11 @@ namespace MQTTnet.Client
|
|||||||
MqttClientDisconnectReason _disconnectReason;
|
MqttClientDisconnectReason _disconnectReason;
|
||||||
|
|
||||||
DateTime _lastPacketSentTimestamp;
|
DateTime _lastPacketSentTimestamp;
|
||||||
|
|
||||||
public MqttClient(IMqttClientAdapterFactory channelFactory, IMqttNetLogger logger)
|
public MqttClient(IMqttClientAdapterFactory channelFactory, IMqttNetLogger logger)
|
||||||
{
|
{
|
||||||
if (logger == null) throw new ArgumentNullException(nameof(logger));
|
|
||||||
|
|
||||||
_adapterFactory = channelFactory ?? throw new ArgumentNullException(nameof(channelFactory));
|
_adapterFactory = channelFactory ?? throw new ArgumentNullException(nameof(channelFactory));
|
||||||
|
_rootLogger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
_logger = logger.WithSource(nameof(MqttClient));
|
_logger = logger.WithSource(nameof(MqttClient));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,8 +66,6 @@ namespace MQTTnet.Client
|
|||||||
remove => _disconnectedEvent.RemoveHandler(value);
|
remove => _disconnectedEvent.RemoveHandler(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMqttApplicationMessageReceivedHandler ApplicationMessageReceivedHandler { get; set; }
|
|
||||||
|
|
||||||
public event Func<MqttApplicationMessageReceivedEventArgs, Task> ApplicationMessageReceivedAsync
|
public event Func<MqttApplicationMessageReceivedEventArgs, Task> ApplicationMessageReceivedAsync
|
||||||
{
|
{
|
||||||
add => _applicationMessageReceivedEvent.AddHandler(value);
|
add => _applicationMessageReceivedEvent.AddHandler(value);
|
||||||
@@ -112,7 +102,7 @@ namespace MQTTnet.Client
|
|||||||
_backgroundCancellationTokenSource = new CancellationTokenSource();
|
_backgroundCancellationTokenSource = new CancellationTokenSource();
|
||||||
var backgroundCancellationToken = _backgroundCancellationTokenSource.Token;
|
var backgroundCancellationToken = _backgroundCancellationTokenSource.Token;
|
||||||
|
|
||||||
var adapter = _adapterFactory.CreateClientAdapter(options);
|
var adapter = _adapterFactory.CreateClientAdapter(options, _rootLogger);
|
||||||
_adapter = adapter;
|
_adapter = adapter;
|
||||||
|
|
||||||
using (var effectiveCancellationToken = CancellationTokenSource.CreateLinkedTokenSource(backgroundCancellationToken, cancellationToken))
|
using (var effectiveCancellationToken = CancellationTokenSource.CreateLinkedTokenSource(backgroundCancellationToken, cancellationToken))
|
||||||
@@ -813,13 +803,7 @@ namespace MQTTnet.Client
|
|||||||
var applicationMessageFactory = new MqttApplicationMessageFactory();
|
var applicationMessageFactory = new MqttApplicationMessageFactory();
|
||||||
var applicationMessage = applicationMessageFactory.Create(publishPacket);
|
var applicationMessage = applicationMessageFactory.Create(publishPacket);
|
||||||
var eventArgs = new MqttApplicationMessageReceivedEventArgs(Options.ClientId, applicationMessage, publishPacket, AcknowledgeReceivedPublishPacket);
|
var eventArgs = new MqttApplicationMessageReceivedEventArgs(Options.ClientId, applicationMessage, publishPacket, AcknowledgeReceivedPublishPacket);
|
||||||
|
|
||||||
var handler = ApplicationMessageReceivedHandler;
|
|
||||||
if (handler != null)
|
|
||||||
{
|
|
||||||
await handler.HandleApplicationMessageReceivedAsync(eventArgs).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
await _applicationMessageReceivedEvent.InvokeAsync(eventArgs).ConfigureAwait(false);
|
await _applicationMessageReceivedEvent.InvokeAsync(eventArgs).ConfigureAwait(false);
|
||||||
|
|
||||||
return eventArgs;
|
return eventArgs;
|
||||||
|
|||||||
@@ -1,16 +1,9 @@
|
|||||||
using MQTTnet.Client.Connecting;
|
|
||||||
using MQTTnet.Client.Disconnecting;
|
|
||||||
using MQTTnet.Client.ExtendedAuthenticationExchange;
|
|
||||||
using MQTTnet.Client.Options;
|
|
||||||
using MQTTnet.Client.Publishing;
|
|
||||||
using MQTTnet.Client.Receiving;
|
|
||||||
using MQTTnet.Client.Subscribing;
|
|
||||||
using MQTTnet.Client.Unsubscribing;
|
|
||||||
using MQTTnet.Protocol;
|
using MQTTnet.Protocol;
|
||||||
using System;
|
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.Packets;
|
||||||
|
|
||||||
namespace MQTTnet.Client
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
@@ -79,39 +72,7 @@ namespace MQTTnet.Client
|
|||||||
client.DisconnectedHandler = handler;
|
client.DisconnectedHandler = handler;
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IMqttClient UseApplicationMessageReceivedHandler(this IMqttClient client, Func<MqttApplicationMessageReceivedEventArgs, Task> handler)
|
|
||||||
{
|
|
||||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
|
||||||
|
|
||||||
if (handler == null)
|
|
||||||
{
|
|
||||||
return client.UseApplicationMessageReceivedHandler((IMqttApplicationMessageReceivedHandler)null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return client.UseApplicationMessageReceivedHandler(new MqttApplicationMessageReceivedHandlerDelegate(handler));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IMqttClient UseApplicationMessageReceivedHandler(this IMqttClient client, Action<MqttApplicationMessageReceivedEventArgs> handler)
|
|
||||||
{
|
|
||||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
|
||||||
|
|
||||||
if (handler == null)
|
|
||||||
{
|
|
||||||
return client.UseApplicationMessageReceivedHandler((IMqttApplicationMessageReceivedHandler)null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return client.UseApplicationMessageReceivedHandler(new MqttApplicationMessageReceivedHandlerDelegate(handler));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IMqttClient UseApplicationMessageReceivedHandler(this IMqttClient client, IMqttApplicationMessageReceivedHandler handler)
|
|
||||||
{
|
|
||||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
|
||||||
|
|
||||||
client.ApplicationMessageReceivedHandler = handler;
|
|
||||||
return client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Task<MqttClientConnectResult> ReconnectAsync(this IMqttClient client)
|
public static Task<MqttClientConnectResult> ReconnectAsync(this IMqttClient client)
|
||||||
{
|
{
|
||||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace MQTTnet.Client.Options
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public interface IMqttClientChannelOptions
|
public interface IMqttClientChannelOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace MQTTnet.Client.Options
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public interface IMqttClientCredentials
|
public interface IMqttClientCredentials
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
using MQTTnet.Client.ExtendedAuthenticationExchange;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using MQTTnet.Diagnostics;
|
||||||
using MQTTnet.Formatter;
|
using MQTTnet.Formatter;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using MQTTnet.Diagnostics.PacketInspection;
|
|
||||||
|
|
||||||
namespace MQTTnet.Client.Options
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public interface IMqttClientOptions
|
public interface IMqttClientOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Net.Security;
|
using System.Net.Security;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Options
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public class MqttClientCertificateValidationCallbackContext
|
public class MqttClientCertificateValidationCallbackContext
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace MQTTnet.Client.Options
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public class MqttClientCredentials : IMqttClientCredentials
|
public class MqttClientCredentials : IMqttClientCredentials
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
using MQTTnet.Client.ExtendedAuthenticationExchange;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using MQTTnet.Diagnostics;
|
||||||
using MQTTnet.Formatter;
|
using MQTTnet.Formatter;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using MQTTnet.Diagnostics.PacketInspection;
|
|
||||||
|
|
||||||
namespace MQTTnet.Client.Options
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public class MqttClientOptions : IMqttClientOptions
|
public class MqttClientOptions : IMqttClientOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
using MQTTnet.Client.ExtendedAuthenticationExchange;
|
using System;
|
||||||
using MQTTnet.Formatter;
|
|
||||||
using MQTTnet.Packets;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using MQTTnet.Diagnostics.PacketInspection;
|
using MQTTnet.Diagnostics;
|
||||||
|
using MQTTnet.Formatter;
|
||||||
|
using MQTTnet.Packets;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Options
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public class MqttClientOptionsBuilder
|
public class MqttClientOptionsBuilder
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Net.Security;
|
|||||||
using System.Security.Authentication;
|
using System.Security.Authentication;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Options
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public class MqttClientOptionsBuilderTlsParameters
|
public class MqttClientOptionsBuilderTlsParameters
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Options
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public class MqttClientOptionsBuilderWebSocketParameters
|
public class MqttClientOptionsBuilderWebSocketParameters
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Options
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public class MqttClientTcpOptions : IMqttClientChannelOptions
|
public class MqttClientTcpOptions : IMqttClientChannelOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Options
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public static class MqttClientTcpOptionsExtensions
|
public static class MqttClientTcpOptionsExtensions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Net.Security;
|
|||||||
using System.Security.Authentication;
|
using System.Security.Authentication;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Options
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public class MqttClientTlsOptions
|
public class MqttClientTlsOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Options
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public class MqttClientWebSocketOptions : IMqttClientChannelOptions
|
public class MqttClientWebSocketOptions : IMqttClientChannelOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace MQTTnet.Client.Options
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public class MqttClientWebSocketProxyOptions
|
public class MqttClientWebSocketProxyOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace MQTTnet.Client.Publishing
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public enum MqttClientPublishReasonCode
|
public enum MqttClientPublishReasonCode
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Publishing
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public sealed class MqttClientPublishResult
|
public sealed class MqttClientPublishResult
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
using MQTTnet.Protocol;
|
using MQTTnet.Protocol;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Publishing
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public sealed class MqttClientPublishResultFactory
|
public sealed class MqttClientPublishResultFactory
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MQTTnet.Client.Receiving
|
|
||||||
{
|
|
||||||
public interface IMqttApplicationMessageReceivedHandler
|
|
||||||
{
|
|
||||||
Task HandleApplicationMessageReceivedAsync(MqttApplicationMessageReceivedEventArgs eventArgs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -4,7 +4,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
|
|
||||||
namespace MQTTnet
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public sealed class MqttApplicationMessageReceivedEventArgs : EventArgs
|
public sealed class MqttApplicationMessageReceivedEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using MQTTnet.Implementations;
|
|
||||||
|
|
||||||
namespace MQTTnet.Client.Receiving
|
|
||||||
{
|
|
||||||
public sealed class MqttApplicationMessageReceivedHandlerDelegate : IMqttApplicationMessageReceivedHandler
|
|
||||||
{
|
|
||||||
readonly Func<MqttApplicationMessageReceivedEventArgs, Task> _handler;
|
|
||||||
|
|
||||||
public MqttApplicationMessageReceivedHandlerDelegate(Action<MqttApplicationMessageReceivedEventArgs> handler)
|
|
||||||
{
|
|
||||||
if (handler == null) throw new ArgumentNullException(nameof(handler));
|
|
||||||
|
|
||||||
_handler = context =>
|
|
||||||
{
|
|
||||||
handler(context);
|
|
||||||
return PlatformAbstractionLayer.CompletedTask;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public MqttApplicationMessageReceivedHandlerDelegate(Func<MqttApplicationMessageReceivedEventArgs, Task> handler)
|
|
||||||
{
|
|
||||||
_handler = handler ?? throw new ArgumentNullException(nameof(handler));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task HandleApplicationMessageReceivedAsync(MqttApplicationMessageReceivedEventArgs context)
|
|
||||||
{
|
|
||||||
return _handler(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace MQTTnet
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public enum MqttApplicationMessageReceivedReasonCode
|
public enum MqttApplicationMessageReceivedReasonCode
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Subscribing
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public sealed class MqttClientSubscribeOptions
|
public sealed class MqttClientSubscribeOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using MQTTnet.Packets;
|
using System;
|
||||||
using MQTTnet.Protocol;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using MQTTnet.Exceptions;
|
using MQTTnet.Exceptions;
|
||||||
|
using MQTTnet.Packets;
|
||||||
|
using MQTTnet.Protocol;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Subscribing
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public sealed class MqttClientSubscribeOptionsBuilder
|
public sealed class MqttClientSubscribeOptionsBuilder
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Subscribing
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public sealed class MqttClientSubscribeResult
|
public sealed class MqttClientSubscribeResult
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace MQTTnet.Client.Subscribing
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public enum MqttClientSubscribeResultCode
|
public enum MqttClientSubscribeResultCode
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Linq;
|
|||||||
using MQTTnet.Exceptions;
|
using MQTTnet.Exceptions;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Subscribing
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public sealed class MqttClientSubscribeResultFactory
|
public sealed class MqttClientSubscribeResultFactory
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace MQTTnet.Client.Subscribing
|
using MQTTnet.Packets;
|
||||||
|
|
||||||
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public sealed class MqttClientSubscribeResultItem
|
public sealed class MqttClientSubscribeResultItem
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Unsubscribing
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public sealed class MqttClientUnsubscribeOptions
|
public sealed class MqttClientUnsubscribeOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using MQTTnet.Packets;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using MQTTnet.Packets;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Unsubscribing
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public class MqttClientUnsubscribeOptionsBuilder
|
public class MqttClientUnsubscribeOptionsBuilder
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Unsubscribing
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public sealed class MqttClientUnsubscribeResult
|
public sealed class MqttClientUnsubscribeResult
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace MQTTnet.Client.Unsubscribing
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public enum MqttClientUnsubscribeResultCode
|
public enum MqttClientUnsubscribeResultCode
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Linq;
|
|||||||
using MQTTnet.Exceptions;
|
using MQTTnet.Exceptions;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Unsubscribing
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public sealed class MqttClientUnsubscribeResultFactory
|
public sealed class MqttClientUnsubscribeResultFactory
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MQTTnet.Client.Unsubscribing
|
namespace MQTTnet.Client
|
||||||
{
|
{
|
||||||
public sealed class MqttClientUnsubscribeResultItem
|
public sealed class MqttClientUnsubscribeResultItem
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MQTTnet.Diagnostics.Logger
|
namespace MQTTnet.Diagnostics
|
||||||
{
|
{
|
||||||
public interface IMqttNetLogger
|
public interface IMqttNetLogger
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MQTTnet.Diagnostics.Logger
|
namespace MQTTnet.Diagnostics
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This logger fires an event when a new message was published.
|
/// This logger fires an event when a new message was published.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace MQTTnet.Diagnostics.Logger
|
namespace MQTTnet.Diagnostics
|
||||||
{
|
{
|
||||||
public enum MqttNetLogLevel
|
public enum MqttNetLogLevel
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MQTTnet.Diagnostics.Logger
|
namespace MQTTnet.Diagnostics
|
||||||
{
|
{
|
||||||
public sealed class MqttNetLogMessage
|
public sealed class MqttNetLogMessage
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MQTTnet.Diagnostics.Logger
|
namespace MQTTnet.Diagnostics
|
||||||
{
|
{
|
||||||
public sealed class MqttNetLogMessagePublishedEventArgs : EventArgs
|
public sealed class MqttNetLogMessagePublishedEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MQTTnet.Diagnostics.Logger
|
namespace MQTTnet.Diagnostics
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This logger does nothing with the messages.
|
/// This logger does nothing with the messages.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MQTTnet.Diagnostics.Logger
|
namespace MQTTnet.Diagnostics
|
||||||
{
|
{
|
||||||
public sealed class MqttNetSourceLogger
|
public sealed class MqttNetSourceLogger
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MQTTnet.Diagnostics.Logger
|
namespace MQTTnet.Diagnostics
|
||||||
{
|
{
|
||||||
public static class MqttNetSourceLoggerExtensions
|
public static class MqttNetSourceLoggerExtensions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace MQTTnet.Diagnostics.PacketInspection
|
namespace MQTTnet.Diagnostics
|
||||||
{
|
{
|
||||||
public interface IMqttPacketInspector
|
public interface IMqttPacketInspector
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace MQTTnet.Diagnostics.PacketInspection
|
namespace MQTTnet.Diagnostics
|
||||||
{
|
{
|
||||||
public enum MqttPacketFlowDirection
|
public enum MqttPacketFlowDirection
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace MQTTnet.Diagnostics.PacketInspection
|
namespace MQTTnet.Diagnostics
|
||||||
{
|
{
|
||||||
public sealed class ProcessMqttPacketContext
|
public sealed class ProcessMqttPacketContext
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace MQTTnet.Diagnostics.Runtime
|
namespace MQTTnet.Diagnostics
|
||||||
{
|
{
|
||||||
public static class TargetFrameworkProvider
|
public static class TargetFrameworkProvider
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using MQTTnet.Client.Options;
|
using MQTTnet.Client;
|
||||||
|
|
||||||
namespace MQTTnet.Extensions
|
namespace MQTTnet.Extensions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using MQTTnet.Client.Options;
|
using MQTTnet.Client;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
|
|
||||||
namespace MQTTnet.Formatter
|
namespace MQTTnet.Formatter
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using MQTTnet.Client.Disconnecting;
|
using MQTTnet.Client;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
using MQTTnet.Protocol;
|
using MQTTnet.Protocol;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using MQTTnet.Client;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
using MQTTnet.Protocol;
|
using MQTTnet.Protocol;
|
||||||
using MQTTnet.Server;
|
using MQTTnet.Server;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using MQTTnet.Client;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
using MQTTnet.Protocol;
|
using MQTTnet.Protocol;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using MQTTnet.Client;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
using MQTTnet.Protocol;
|
using MQTTnet.Protocol;
|
||||||
using MQTTnet.Server;
|
using MQTTnet.Server;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using MQTTnet.Client;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
using MQTTnet.Protocol;
|
using MQTTnet.Protocol;
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ namespace MQTTnet.Formatter
|
|||||||
Payload = connectPacket.WillMessage,
|
Payload = connectPacket.WillMessage,
|
||||||
QualityOfServiceLevel = connectPacket.WillQoS,
|
QualityOfServiceLevel = connectPacket.WillQoS,
|
||||||
Retain = connectPacket.WillRetain,
|
Retain = connectPacket.WillRetain,
|
||||||
Dup = false,
|
|
||||||
Properties =
|
Properties =
|
||||||
{
|
{
|
||||||
ContentType = connectPacket.WillProperties.ContentType,
|
ContentType = connectPacket.WillProperties.ContentType,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
using MQTTnet.Server.Internal;
|
using MQTTnet.Server;
|
||||||
|
|
||||||
namespace MQTTnet.Formatter
|
namespace MQTTnet.Formatter
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using MQTTnet.Client.Subscribing;
|
using MQTTnet.Client;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
|
|
||||||
namespace MQTTnet.Formatter
|
namespace MQTTnet.Formatter
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
using MQTTnet.Server.Internal;
|
using MQTTnet.Server;
|
||||||
|
|
||||||
namespace MQTTnet.Formatter
|
namespace MQTTnet.Formatter
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using MQTTnet.Client.Unsubscribing;
|
using MQTTnet.Client;
|
||||||
using MQTTnet.Packets;
|
using MQTTnet.Packets;
|
||||||
|
|
||||||
namespace MQTTnet.Formatter
|
namespace MQTTnet.Formatter
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MQTTnet.Client.Publishing;
|
using MQTTnet.Client;
|
||||||
|
|
||||||
namespace MQTTnet
|
namespace MQTTnet
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,17 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MQTTnet.Client.Receiving;
|
using MQTTnet.Client;
|
||||||
|
|
||||||
namespace MQTTnet
|
namespace MQTTnet
|
||||||
{
|
{
|
||||||
public interface IMqttApplicationMessageReceiver
|
public interface IMqttApplicationMessageReceiver
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the application message received handler that is fired every time a new message is received on the client's subscriptions.
|
|
||||||
/// Hint: Initialize handlers before you connect the client to avoid issues.
|
|
||||||
/// </summary>
|
|
||||||
IMqttApplicationMessageReceivedHandler ApplicationMessageReceivedHandler { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fired when an application message was received.
|
/// Fired when an application message was received.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,23 +1,15 @@
|
|||||||
using MQTTnet.Adapter;
|
using MQTTnet.Adapter;
|
||||||
using MQTTnet.Client.Options;
|
|
||||||
using MQTTnet.Diagnostics;
|
using MQTTnet.Diagnostics;
|
||||||
using MQTTnet.Formatter;
|
using MQTTnet.Formatter;
|
||||||
using System;
|
using System;
|
||||||
using MQTTnet.Channel;
|
using MQTTnet.Channel;
|
||||||
using MQTTnet.Diagnostics.Logger;
|
using MQTTnet.Client;
|
||||||
|
|
||||||
namespace MQTTnet.Implementations
|
namespace MQTTnet.Implementations
|
||||||
{
|
{
|
||||||
public class MqttClientAdapterFactory : IMqttClientAdapterFactory
|
public sealed class MqttClientAdapterFactory : IMqttClientAdapterFactory
|
||||||
{
|
{
|
||||||
readonly IMqttNetLogger _logger;
|
public IMqttChannelAdapter CreateClientAdapter(IMqttClientOptions options, IMqttNetLogger logger)
|
||||||
|
|
||||||
public MqttClientAdapterFactory(IMqttNetLogger logger)
|
|
||||||
{
|
|
||||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMqttChannelAdapter CreateClientAdapter(IMqttClientOptions options)
|
|
||||||
{
|
{
|
||||||
if (options == null) throw new ArgumentNullException(nameof(options));
|
if (options == null) throw new ArgumentNullException(nameof(options));
|
||||||
|
|
||||||
@@ -43,7 +35,7 @@ namespace MQTTnet.Implementations
|
|||||||
}
|
}
|
||||||
|
|
||||||
var packetFormatterAdapter = new MqttPacketFormatterAdapter(options.ProtocolVersion, new MqttPacketWriter());
|
var packetFormatterAdapter = new MqttPacketFormatterAdapter(options.ProtocolVersion, new MqttPacketWriter());
|
||||||
return new MqttChannelAdapter(channel, packetFormatterAdapter, options.PacketInspector, _logger);
|
return new MqttChannelAdapter(channel, packetFormatterAdapter, options.PacketInspector, logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user