Bläddra i källkod

Add a method for clearing all retained messages at the server.

release/3.x.x
Christian Kratky 6 år sedan
förälder
incheckning
56a1530cee
4 ändrade filer med 19 tillägg och 0 borttagningar
  1. +2
    -0
      Build/MQTTnet.nuspec
  2. +2
    -0
      Source/MQTTnet/Server/IMqttServer.cs
  3. +10
    -0
      Source/MQTTnet/Server/MqttRetainedMessagesManager.cs
  4. +5
    -0
      Source/MQTTnet/Server/MqttServer.cs

+ 2
- 0
Build/MQTTnet.nuspec Visa fil

@@ -11,7 +11,9 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker).</description>
<releaseNotes>* [Core] Added all factory methods to the factory interface.
* [Core] Fixed an issue with cancellation token handling (thanks to @acrabb).
* [Server] Added a new overload for configuring the ASP.net integration (thanks to @JanEggers).
* [Server] Added a method for clearing all retained messages.
</releaseNotes>
<copyright>Copyright Christian Kratky 2016-2018</copyright>
<tags>MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin</tags>


+ 2
- 0
Source/MQTTnet/Server/IMqttServer.cs Visa fil

@@ -23,5 +23,7 @@ namespace MQTTnet.Server

Task StartAsync(IMqttServerOptions options);
Task StopAsync();

Task ClearRetainedMessagesAsync();
}
}

+ 10
- 0
Source/MQTTnet/Server/MqttRetainedMessagesManager.cs Visa fil

@@ -84,6 +84,16 @@ namespace MQTTnet.Server
return retainedMessages;
}

public Task ClearMessagesAsync()
{
lock (_messages)
{
_messages.Clear();
}

return _options.Storage.SaveRetainedMessagesAsync(new List<MqttApplicationMessage>());
}

private async Task HandleMessageInternalAsync(string clientId, MqttApplicationMessage applicationMessage)
{
var saveIsRequired = false;


+ 5
- 0
Source/MQTTnet/Server/MqttServer.cs Visa fil

@@ -129,6 +129,11 @@ namespace MQTTnet.Server
}
}

public Task ClearRetainedMessagesAsync()
{
return _retainedMessagesManager?.ClearMessagesAsync();
}

internal void OnClientConnected(string clientId)
{
_logger.Info("Client '{0}': Connected.", clientId);


Laddar…
Avbryt
Spara