Kaynağa Gözat

Cleanup.

release/3.x.x
Christian Kratky 5 yıl önce
ebeveyn
işleme
2c927c5995
3 değiştirilmiş dosya ile 11 ekleme ve 54 silme
  1. +1
    -1
      README.md
  2. +0
    -51
      Source/MQTTnet.AspnetCore/TopicFilterBuilder.cs
  3. +10
    -2
      Source/MQTTnet.Server/Logging/MqttNetLoggerWrapper.cs

+ 1
- 1
README.md Dosyayı Görüntüle

@@ -26,7 +26,7 @@ MQTTnet is a high performance .NET library for MQTT based communication. It prov
* Uniform API across all supported versions of the MQTT protocol
* Interfaces included for mocking and testing
* Access to internal trace messages
* Unit tested (~150 tests)
* Unit tested (~200 tests)
* No external dependencies

\* Tested on local machine (Intel i7 8700K) with MQTTnet client and server running in the same process using the TCP channel. The app for verification is part of this repository and stored in _/Tests/MQTTnet.TestApp.NetCore_.


+ 0
- 51
Source/MQTTnet.AspnetCore/TopicFilterBuilder.cs Dosyayı Görüntüle

@@ -1,51 +0,0 @@
using MQTTnet.Exceptions;
using MQTTnet.Protocol;

namespace MQTTnet
{
public class TopicFilterBuilder
{
private MqttQualityOfServiceLevel _qualityOfServiceLevel = MqttQualityOfServiceLevel.AtMostOnce;
private string _topic;

public TopicFilterBuilder WithTopic(string topic)
{
_topic = topic;
return this;
}

public TopicFilterBuilder WithQualityOfServiceLevel(MqttQualityOfServiceLevel qualityOfServiceLevel)
{
_qualityOfServiceLevel = qualityOfServiceLevel;
return this;
}

public TopicFilterBuilder WithAtLeastOnceQoS()
{
_qualityOfServiceLevel = MqttQualityOfServiceLevel.AtLeastOnce;
return this;
}

public TopicFilterBuilder WithAtMostOnceQoS()
{
_qualityOfServiceLevel = MqttQualityOfServiceLevel.AtMostOnce;
return this;
}

public TopicFilterBuilder WithExactlyOnceQoS()
{
_qualityOfServiceLevel = MqttQualityOfServiceLevel.ExactlyOnce;
return this;
}

public TopicFilter Build()
{
if (string.IsNullOrEmpty(_topic))
{
throw new MqttProtocolViolationException("Topic is not set.");
}

return new TopicFilter { Topic = _topic, QualityOfServiceLevel = _qualityOfServiceLevel };
}
}
}

+ 10
- 2
Source/MQTTnet.Server/Logging/MqttNetLoggerWrapper.cs Dosyayı Görüntüle

@@ -1,4 +1,5 @@
using System;
using System.Threading;
using Microsoft.Extensions.Logging;
using MQTTnet.Diagnostics;

@@ -14,7 +15,7 @@ namespace MQTTnet.Server.Logging
}

public event EventHandler<MqttNetLogMessagePublishedEventArgs> LogMessagePublished;
public IMqttNetChildLogger CreateChildLogger(string source = null)
{
return new MqttNetChildLoggerWrapper(source, this);
@@ -24,8 +25,15 @@ namespace MQTTnet.Server.Logging
{
var convertedLogLevel = ConvertLogLevel(logLevel);
_logger.Log(convertedLogLevel, exception, message, parameters);
}

var logMessagePublishedEvent = LogMessagePublished;
if (logMessagePublishedEvent != null)
{
var logMessage = new MqttNetLogMessage(null, DateTime.UtcNow, Thread.CurrentThread.ManagedThreadId, source, logLevel, message, exception);
logMessagePublishedEvent.Invoke(this, new MqttNetLogMessagePublishedEventArgs(logMessage));
}
}
private static LogLevel ConvertLogLevel(MqttNetLogLevel logLevel)
{
switch (logLevel)


Yükleniyor…
İptal
Kaydet