Explorar el Código

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

release/3.x.x
Christian Kratky hace 6 años
padre
commit
56a1530cee
Se han modificado 4 ficheros con 19 adiciones y 0 borrados
  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 Ver fichero

@@ -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 Ver fichero

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

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

Task ClearRetainedMessagesAsync();
}
}

+ 10
- 0
Source/MQTTnet/Server/MqttRetainedMessagesManager.cs Ver fichero

@@ -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 Ver fichero

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

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

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


Cargando…
Cancelar
Guardar