Read payload as string
All checks were successful
Build, Push and Run Container / build (push) Successful in 24s
All checks were successful
Build, Push and Run Container / build (push) Successful in 24s
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Text;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using MQTTnet;
|
using MQTTnet;
|
||||||
|
|
||||||
@@ -21,8 +22,9 @@ public class MQTTClient : IHostedService
|
|||||||
|
|
||||||
this.client.ApplicationMessageReceivedAsync += (e) =>
|
this.client.ApplicationMessageReceivedAsync += (e) =>
|
||||||
{
|
{
|
||||||
logger.LogInformation("Message received: {Message}", e.ApplicationMessage.Payload);
|
string message = Encoding.UTF8.GetString(e.ApplicationMessage.Payload);
|
||||||
messageProcessor.ProcessMessage(e.ApplicationMessage.Payload.ToString());
|
logger.LogInformation("Message received: {Message}", message);
|
||||||
|
messageProcessor.ProcessMessage(message);
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user