diff --git a/src/CaseOnline.Azure.WebJobs.Extensions.Mqtt/Bindings/MqttTriggerBinding.cs b/src/CaseOnline.Azure.WebJobs.Extensions.Mqtt/Bindings/MqttTriggerBinding.cs index aa91bd8..0670f39 100644 --- a/src/CaseOnline.Azure.WebJobs.Extensions.Mqtt/Bindings/MqttTriggerBinding.cs +++ b/src/CaseOnline.Azure.WebJobs.Extensions.Mqtt/Bindings/MqttTriggerBinding.cs @@ -51,22 +51,22 @@ public MqttTriggerBinding(ParameterInfo parameter, MqttConnection connection, To public Task BindAsync(object value, ValueBindingContext context) { - _logger.LogDebug("MqttTriggerBinding.BindAsync"); - var valueProvider = new ValueProvider(value); return Task.FromResult(new TriggerData(valueProvider, _emptyBindingData)); } public Task CreateListenerAsync(ListenerFactoryContext context) { - _logger.LogDebug("MqttTriggerBinding.CreateListenerAsync"); - if (context == null) { throw new ArgumentNullException(nameof(context)); } - return Task.FromResult(new MqttListener(_connection, _topics, context.Executor, _logger)); + var listener = new MqttListener(_connection, _topics, context.Executor, _logger); + + _logger.LogDebug("Listener for MqttTriggerBinding created"); + + return Task.FromResult(listener); } public ParameterDescriptor ToParameterDescriptor() diff --git a/src/CaseOnline.Azure.WebJobs.Extensions.Mqtt/CaseOnline.Azure.WebJobs.Extensions.Mqtt.csproj b/src/CaseOnline.Azure.WebJobs.Extensions.Mqtt/CaseOnline.Azure.WebJobs.Extensions.Mqtt.csproj index a04a67a..9fe0e14 100644 --- a/src/CaseOnline.Azure.WebJobs.Extensions.Mqtt/CaseOnline.Azure.WebJobs.Extensions.Mqtt.csproj +++ b/src/CaseOnline.Azure.WebJobs.Extensions.Mqtt/CaseOnline.Azure.WebJobs.Extensions.Mqtt.csproj @@ -15,7 +15,13 @@ CaseOnline.Azure.WebJobs.Extensions.Mqtt CaseOnline.Azure.WebJobs.Extensions.Mqtt CaseOnline.Azure.WebJobs.Extensions.Mqtt - This package contains the runtime assemblies for CaseOnline.Azure.WebJobs.Extensions.Mqtt. For more information, please visit https://github.com/keesschollaart81/CaseOnline.Azure.WebJobs.Extensions.Mqtt. + + This package enables you to: + + * Trigger an Azure Function based on a MQTT Subscription + * Publish a message to a MQTT topic as a result of an Azure Function. + + For more information, please visit https://github.com/keesschollaart81/CaseOnline.Azure.WebJobs.Extensions.Mqtt. https://raw.githubusercontent.com/keesschollaart81/CaseOnline.Azure.WebJobs.Extensions.Mqtt/master/logo.png true analyzers.ruleset @@ -37,6 +43,6 @@ - + \ No newline at end of file diff --git a/src/CaseOnline.Azure.WebJobs.Extensions.Mqtt/Listeners/MqttConnection.cs b/src/CaseOnline.Azure.WebJobs.Extensions.Mqtt/Listeners/MqttConnection.cs index ce52c34..3cb04ea 100644 --- a/src/CaseOnline.Azure.WebJobs.Extensions.Mqtt/Listeners/MqttConnection.cs +++ b/src/CaseOnline.Azure.WebJobs.Extensions.Mqtt/Listeners/MqttConnection.cs @@ -41,7 +41,7 @@ public MqttConnection(IMqttClientFactory mqttClientFactory, MqttConfiguration co /// ; public override string ToString() { - return $"Connection for config: {_config.ToString()}, connected: {Connected}"; + return $"Connection for config: {_config.ToString()}, currently connected: {Connected}"; } /// @@ -88,7 +88,7 @@ private void ManagedMqttClientApplicationMessageProcessed(object sender, Applica { if (e.HasFailed) { - _logger.LogError($"Message could not be processed for {this}, message: {e.Exception?.Message}", e.Exception); + _logger.LogError($"Message could not be processed for {this}, message: '{e.Exception?.Message}'", e.Exception); } } @@ -96,14 +96,14 @@ private void ManagedMqttClientDisconnected(object sender, MqttClientDisconnected { Connected = false; Connecting = false; - _logger.LogWarning($"MqttConnection Disconnected, previous connectivity state '{e.ClientWasConnected}' for {this}, message: {e.Exception?.Message}", e.Exception); + _logger.LogWarning($"MqttConnection Disconnected, previous connectivity state '{e.ClientWasConnected}' for {this}, message: '{e.Exception?.Message}'", e.Exception); } private void ManagedMqttClientConnected(object sender, MqttClientConnectedEventArgs e) { Connected = true; Connecting = false; - _logger.LogInformation($"MqttConnection Connected, IsSessionPresent: '{e.IsSessionPresent}' for {this}"); + _logger.LogInformation($"MqttConnection Connected for {this}"); } private void ManagedMqttClientApplicationMessageReceived(object sender, MqttApplicationMessageReceivedEventArgs mqttApplicationMessageReceivedEventArgs) diff --git a/src/ExampleFunctions/ExampleFunctions.csproj b/src/ExampleFunctions/ExampleFunctions.csproj index d23306a..a27d420 100644 --- a/src/ExampleFunctions/ExampleFunctions.csproj +++ b/src/ExampleFunctions/ExampleFunctions.csproj @@ -4,8 +4,8 @@ v2 - - + + diff --git a/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests.csproj b/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests.csproj index 223711b..99a5200 100644 --- a/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests.csproj +++ b/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests.csproj @@ -53,8 +53,8 @@ - - + + diff --git a/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/Helpers/MqttLogger.cs b/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/Helpers/MqttLogger.cs index 4e83fb9..f38ae8a 100644 --- a/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/Helpers/MqttLogger.cs +++ b/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/Helpers/MqttLogger.cs @@ -52,5 +52,10 @@ public void Warning(string message, params object[] parameters) { Logger.LogWarning(message, parameters); } + + public void Verbose(string message, params object[] parameters) + { + Logger.LogTrace(message, parameters); + } } } diff --git a/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/Helpers/MqttServerHelper.cs b/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/Helpers/MqttServerHelper.cs index 211edec..84e3e0d 100644 --- a/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/Helpers/MqttServerHelper.cs +++ b/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/Helpers/MqttServerHelper.cs @@ -46,7 +46,7 @@ private async Task StartMqttServer() MqttTcpChannel.CustomCertificateValidationCallback = RemoteValidation; var logger = new MqttLogger(_logger); var factory = new MqttFactory(); - _mqttServer = factory.CreateMqttServer(new List { new MqttServerAdapter(logger) }, logger); + _mqttServer = factory.CreateMqttServer(new List { new MqttTcpServerAdapter(logger) }, logger); _mqttServer.Started += Started; _mqttServer.ClientConnected += ClientConnected; _mqttServer.ClientDisconnected += ClientDisconnected;