diff --git a/Build/MQTTnet.nuspec b/Build/MQTTnet.nuspec index e055a25..9e25687 100644 --- a/Build/MQTTnet.nuspec +++ b/Build/MQTTnet.nuspec @@ -26,6 +26,7 @@ * [Server] Added interceptor for unsubscriptions. * [Server] Removed exceptions when user properties are set with MQTT protocol version 3.1 * [Server] Added custom session items to the client status. +* [Server] Added option to check whether the server is already started properly or not. * [MQTTnet.AspNetCore] improved compatibility with AspNetCore 3.1 * [MQTTnet.Server] Added interceptor for unsubscriptions. diff --git a/Source/MQTTnet/Server/IMqttServer.cs b/Source/MQTTnet/Server/IMqttServer.cs index c080f4e..41c6dc0 100644 --- a/Source/MQTTnet/Server/IMqttServer.cs +++ b/Source/MQTTnet/Server/IMqttServer.cs @@ -27,5 +27,7 @@ namespace MQTTnet.Server Task StartAsync(IMqttServerOptions options); Task StopAsync(); + + bool IsStarted { get; } } } \ No newline at end of file diff --git a/Source/MQTTnet/Server/MqttServer.cs b/Source/MQTTnet/Server/MqttServer.cs index ea687eb..a8c4369 100644 --- a/Source/MQTTnet/Server/MqttServer.cs +++ b/Source/MQTTnet/Server/MqttServer.cs @@ -190,6 +190,8 @@ namespace MQTTnet.Server return _retainedMessagesManager?.ClearMessagesAsync(); } + public bool IsStarted => _cancellationTokenSource != null; + private Task OnHandleClient(IMqttChannelAdapter channelAdapter) { return _clientSessionsManager.HandleClientConnectionAsync(channelAdapter);