Skip to content

Commit 1b4cb4c

Browse files
author
Anton Smolkov
committed
Change return type from MqttPublishPacket to MqttPacketWithIdentifier
1 parent f96c10c commit 1b4cb4c

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

Source/MQTTnet.Server/Status/MqttSessionStatus.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public Task DeleteAsync()
4848
/// <returns>
4949
/// A task that represents the asynchronous operation. The result contains the delivered MQTT publish packet.
5050
/// </returns>
51-
public async Task<MqttPublishPacket> DeliverApplicationMessageAsync(MqttApplicationMessage applicationMessage)
51+
public async Task<MqttPacketWithIdentifier> DeliverApplicationMessageAsync(MqttApplicationMessage applicationMessage)
5252
{
5353
ArgumentNullException.ThrowIfNull(applicationMessage);
5454

@@ -57,7 +57,7 @@ public async Task<MqttPublishPacket> DeliverApplicationMessageAsync(MqttApplicat
5757

5858
var mqttPacket = await packetBusItem.WaitAsync();
5959

60-
return (MqttPublishPacket)mqttPacket;
60+
return (MqttPacketWithIdentifier)mqttPacket;
6161
}
6262

6363
/// <summary>
@@ -72,7 +72,7 @@ public async Task<MqttPublishPacket> DeliverApplicationMessageAsync(MqttApplicat
7272
/// However, an existing message in the queue may be <b>dropped later</b> to make room for the newly enqueued message.
7373
/// Such dropped messages can be tracked by subscribing to <see cref="MqttServer.QueuedApplicationMessageOverwrittenAsync"/> event.
7474
/// </remarks>
75-
public bool TryEnqueueApplicationMessage(MqttApplicationMessage applicationMessage, out MqttPublishPacket publishPacket)
75+
public bool TryEnqueueApplicationMessage(MqttApplicationMessage applicationMessage, out MqttPacketWithIdentifier publishPacket)
7676
{
7777
ArgumentNullException.ThrowIfNull(applicationMessage);
7878

Source/MQTTnet.Tests/Server/Injection_Tests.cs

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.VisualStudio.TestTools.UnitTesting;
44
using MQTTnet.Internal;
55
using MQTTnet.Packets;
6+
using MQTTnet.Protocol;
67
using MQTTnet.Server;
78
using MQTTnet.Server.Exceptions;
89

@@ -28,7 +29,10 @@ public async Task Enqueue_Application_Message_At_Session_Level()
2829
await receiver1.SubscribeAsync("#");
2930
await receiver2.SubscribeAsync("#");
3031

31-
var message = new MqttApplicationMessageBuilder().WithTopic("InjectedOne").Build();
32+
var message = new MqttApplicationMessageBuilder()
33+
.WithQualityOfServiceLevel(MqttQualityOfServiceLevel.AtLeastOnce)
34+
.WithTopic("InjectedOne").Build();
35+
3236
var enqueued = clientStatus.TryEnqueueApplicationMessage(message, out var publishPacket);
3337

3438
Assert.IsTrue(enqueued);
@@ -215,7 +219,10 @@ public async Task Deliver_Application_Message_At_Session_Level()
215219
await receiver1.SubscribeAsync("#");
216220
await receiver2.SubscribeAsync("#");
217221

218-
var mqttApplicationMessage = new MqttApplicationMessageBuilder().WithTopic("InjectedOne").Build();
222+
var mqttApplicationMessage = new MqttApplicationMessageBuilder()
223+
.WithTopic("InjectedOne")
224+
.WithQualityOfServiceLevel(MqttQualityOfServiceLevel.AtLeastOnce)
225+
.Build();
219226
var publishPacket = await clientStatus.DeliverApplicationMessageAsync(mqttApplicationMessage);
220227

221228
await LongTestDelay();

0 commit comments

Comments
 (0)