mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-17 09:43:05 +08:00
Restore undelivered event.
This commit is contained in:
@@ -407,14 +407,7 @@ namespace MQTTnet.Server.Internal
|
||||
}
|
||||
|
||||
_logger.Verbose("Client '{0}': Queued application message with topic '{1}'.", clientSession.Id, applicationMessage.Topic);
|
||||
|
||||
// var queuedApplicationMessage = new MqttQueuedApplicationMessage
|
||||
// {
|
||||
// ApplicationMessage = applicationMessage,
|
||||
// SubscriptionQualityOfServiceLevel = checkSubscriptionsResult.QualityOfServiceLevel,
|
||||
// SubscriptionIdentifiers = checkSubscriptionsResult.SubscriptionIdentifiers
|
||||
// };
|
||||
|
||||
|
||||
var newPublishPacket = _packetFactories.Publish.Create(applicationMessage);
|
||||
newPublishPacket.QualityOfServiceLevel = checkSubscriptionsResult.QualityOfServiceLevel;
|
||||
newPublishPacket.Properties.SubscriptionIdentifiers.AddRange(checkSubscriptionsResult.SubscriptionIdentifiers);
|
||||
@@ -441,15 +434,11 @@ namespace MQTTnet.Server.Internal
|
||||
|
||||
if (deliveryCount == 0)
|
||||
{
|
||||
// TODO: Addd event for not delivered publish packets.
|
||||
// var undeliveredMessageInterceptor = _options.UndeliveredMessageInterceptor;
|
||||
// if (undeliveredMessageInterceptor == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // The delegate signature is the same as for regular message interceptor. So the call is fine and just uses a different interceptor.
|
||||
// await InterceptApplicationMessageAsync(undeliveredMessageInterceptor, sender, applicationMessage).ConfigureAwait(false);
|
||||
await _eventContainer.ApplicationMessageNotConsumedEvent.InvokeAsync(() => new MqttApplicationMessageNotConsumedEventArgs
|
||||
{
|
||||
ApplicationMessage = applicationMessage,
|
||||
SenderClientId = senderClientId
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
||||
@@ -28,6 +28,9 @@ namespace MQTTnet.Server.Internal
|
||||
public AsyncEvent<MqttServerClientUnsubscribedTopicEventArgs> ClientUnsubscribedTopicEvent { get; } = new AsyncEvent<MqttServerClientUnsubscribedTopicEventArgs>();
|
||||
|
||||
public AsyncEvent<PreparingMqttClientSessionEventArgs> PreparingClientSessionEvent { get; } = new AsyncEvent<PreparingMqttClientSessionEventArgs>();
|
||||
|
||||
public AsyncEvent<MqttApplicationMessageNotConsumedEventArgs> ApplicationMessageNotConsumedEvent { get; } = new AsyncEvent<MqttApplicationMessageNotConsumedEventArgs>();
|
||||
|
||||
public AsyncEvent<EventArgs> StartedEvent { get; } = new AsyncEvent<EventArgs>();
|
||||
|
||||
public AsyncEvent<EventArgs> StoppedEvent { get; } = new AsyncEvent<EventArgs>();
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace MQTTnet.Server
|
||||
{
|
||||
public sealed class MqttApplicationMessageNotConsumedEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the application message which was not consumed by any client.
|
||||
/// </summary>
|
||||
public MqttApplicationMessage ApplicationMessage { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ID of the client which has sent the affected application message.
|
||||
/// </summary>
|
||||
public string SenderClientId { get; internal set; }
|
||||
}
|
||||
}
|
||||
@@ -107,6 +107,12 @@ namespace MQTTnet.Server
|
||||
remove => _eventContainer.PreparingClientSessionEvent.RemoveHandler(value);
|
||||
}
|
||||
|
||||
public event Func<MqttApplicationMessageNotConsumedEventArgs, Task> ApplicationMessageNotConsumedAsync
|
||||
{
|
||||
add => _eventContainer.ApplicationMessageNotConsumedEvent.AddHandler(value);
|
||||
remove => _eventContainer.ApplicationMessageNotConsumedEvent.RemoveHandler(value);
|
||||
}
|
||||
|
||||
public bool IsStarted => _cancellationTokenSource != null;
|
||||
|
||||
public Task<IList<IMqttClientStatus>> GetClientStatusAsync()
|
||||
|
||||
Reference in New Issue
Block a user