Skip to content

Commit

Permalink
Set the retain flag according to RFC to delete retained messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
chkr1011 committed Feb 18, 2024
1 parent b575af8 commit 3a771f0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Source/Pages/Inflight/InflightPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,12 @@ void OnDeleteRetainedMessageRequested(object? sender, EventArgs e)
{
try
{
// To delete a retained message it is important to set the body to an empty
// one and setting the retain flag to _true_ as well!
var message = new MqttApplicationMessageBuilder().WithTopic(item.Topic)
.WithQualityOfServiceLevel(item.QualityOfServiceLevel)
.WithPayload(ArraySegment<byte>.Empty)
.WithRetainFlag()
.Build();

await _mqttClientService.Publish(message, CancellationToken.None);
Expand Down

0 comments on commit 3a771f0

Please sign in to comment.