You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

36 lines
1.2 KiB

  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. using System;
  5. using System.Threading.Tasks;
  6. namespace MQTTnet.Extensions.ManagedClient
  7. {
  8. public class ApplicationMessageSkippedHandlerDelegate : IApplicationMessageSkippedHandler
  9. {
  10. private readonly Func<ApplicationMessageSkippedEventArgs, Task> _handler;
  11. public ApplicationMessageSkippedHandlerDelegate(Action<ApplicationMessageSkippedEventArgs> handler)
  12. {
  13. if (handler == null) throw new ArgumentNullException(nameof(handler));
  14. _handler = eventArgs =>
  15. {
  16. handler(eventArgs);
  17. return Task.FromResult(0);
  18. };
  19. }
  20. public ApplicationMessageSkippedHandlerDelegate(Func<ApplicationMessageSkippedEventArgs, Task> handler)
  21. {
  22. _handler = handler ?? throw new ArgumentNullException(nameof(handler));
  23. }
  24. public Task HandleApplicationMessageSkippedAsync(ApplicationMessageSkippedEventArgs eventArgs)
  25. {
  26. return _handler(eventArgs);
  27. }
  28. }
  29. }