mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-15 00:15:15 +08:00
32 lines
1.0 KiB
C#
32 lines
1.0 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MQTTnet.Extensions.ManagedClient
|
|
{
|
|
public class ApplicationMessageProcessedHandlerDelegate : IApplicationMessageProcessedHandler
|
|
{
|
|
private readonly Func<ApplicationMessageProcessedEventArgs, Task> _handler;
|
|
|
|
public ApplicationMessageProcessedHandlerDelegate(Action<ApplicationMessageProcessedEventArgs> handler)
|
|
{
|
|
if (handler == null) throw new ArgumentNullException(nameof(handler));
|
|
|
|
_handler = context =>
|
|
{
|
|
handler(context);
|
|
return Task.FromResult(0);
|
|
};
|
|
}
|
|
|
|
public ApplicationMessageProcessedHandlerDelegate(Func<ApplicationMessageProcessedEventArgs, Task> handler)
|
|
{
|
|
_handler = handler ?? throw new ArgumentNullException(nameof(handler));
|
|
}
|
|
|
|
public Task HandleApplicationMessageProcessedAsync(ApplicationMessageProcessedEventArgs eventArgs)
|
|
{
|
|
return _handler(eventArgs);
|
|
}
|
|
}
|
|
}
|