mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-27 08:42:37 +08:00
@@ -6,6 +6,11 @@ namespace MQTTnet.Core.Client
|
|||||||
public interface IMqttClientOptions
|
public interface IMqttClientOptions
|
||||||
{
|
{
|
||||||
string ClientId { get; }
|
string ClientId { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The LogId is used to create a scope to correlate logging. If no value is provided the ClientId is used instead
|
||||||
|
/// </summary>
|
||||||
|
string LogId { get; }
|
||||||
IMqttClientCredentials Credentials { get; }
|
IMqttClientCredentials Credentials { get; }
|
||||||
bool CleanSession { get; }
|
bool CleanSession { get; }
|
||||||
MqttApplicationMessage WillMessage { get; }
|
MqttApplicationMessage WillMessage { get; }
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace MQTTnet.Core.Client
|
|||||||
|
|
||||||
_adapter = _communicationAdapterFactory.CreateClientMqttCommunicationAdapter(options);
|
_adapter = _communicationAdapterFactory.CreateClientMqttCommunicationAdapter(options);
|
||||||
|
|
||||||
_scopeHandle = _logger.BeginScope(options.ClientId);
|
_scopeHandle = _logger.BeginScope(options.LogId ?? options.ClientId);
|
||||||
_logger.LogTrace("Trying to connect with server.");
|
_logger.LogTrace("Trying to connect with server.");
|
||||||
await _adapter.ConnectAsync(_options.CommunicationTimeout).ConfigureAwait(false);
|
await _adapter.ConnectAsync(_options.CommunicationTimeout).ConfigureAwait(false);
|
||||||
_logger.LogTrace("Connection with server established.");
|
_logger.LogTrace("Connection with server established.");
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ namespace MQTTnet.Core.Client
|
|||||||
|
|
||||||
public string ClientId { get; set; } = Guid.NewGuid().ToString("N");
|
public string ClientId { get; set; } = Guid.NewGuid().ToString("N");
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string LogId { get; set; }
|
||||||
|
|
||||||
public bool CleanSession { get; set; } = true;
|
public bool CleanSession { get; set; } = true;
|
||||||
|
|
||||||
public IMqttClientCredentials Credentials { get; set; } = new MqttClientCredentials();
|
public IMqttClientCredentials Credentials { get; set; } = new MqttClientCredentials();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Hosting;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.FileProviders;
|
using Microsoft.Extensions.FileProviders;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using MQTTnet.AspnetCore;
|
using MQTTnet.AspNetCore;
|
||||||
using MQTTnet.Core;
|
using MQTTnet.Core;
|
||||||
using MQTTnet.Core.Client;
|
using MQTTnet.Core.Client;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user