using System; using System.Threading.Tasks; namespace MQTTnet.Server { public class MqttServerApplicationMessageInterceptorDelegate : IMqttServerApplicationMessageInterceptor { private readonly Func _callback; public MqttServerApplicationMessageInterceptorDelegate(Action callback) { if (callback == null) throw new ArgumentNullException(nameof(callback)); _callback = context => { callback(context); return Task.FromResult(0); }; } public MqttServerApplicationMessageInterceptorDelegate(Func callback) { _callback = callback ?? throw new ArgumentNullException(nameof(callback)); } public Task InterceptApplicationMessagePublishAsync(MqttApplicationMessageInterceptorContext context) { return _callback(context); } } }