mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-28 01:02:37 +08:00
33 lines
909 B
C#
33 lines
909 B
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using MQTTnet.Implementations;
|
|
|
|
namespace MQTTnet.Server
|
|
{
|
|
public sealed class MqttServerStartedHandlerDelegate : IMqttServerStartedHandler
|
|
{
|
|
readonly Func<EventArgs, Task> _handler;
|
|
|
|
public MqttServerStartedHandlerDelegate(Action<EventArgs> handler)
|
|
{
|
|
if (handler == null) throw new ArgumentNullException(nameof(handler));
|
|
|
|
_handler = eventArgs =>
|
|
{
|
|
handler(eventArgs);
|
|
return PlatformAbstractionLayer.CompletedTask;
|
|
};
|
|
}
|
|
|
|
public MqttServerStartedHandlerDelegate(Func<EventArgs, Task> handler)
|
|
{
|
|
_handler = handler ?? throw new ArgumentNullException(nameof(handler));
|
|
}
|
|
|
|
public Task HandleServerStartedAsync(EventArgs eventArgs)
|
|
{
|
|
return _handler(eventArgs);
|
|
}
|
|
}
|
|
}
|