mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-30 18:56:30 +08:00
Add more function mappings for MQTTnet Server.
This commit is contained in:
@@ -4,6 +4,6 @@ namespace MQTTnet.Client.Receiving
|
||||
{
|
||||
public interface IMqttApplicationMessageHandler
|
||||
{
|
||||
Task HandleApplicationMessageAsync(MqttApplicationMessageHandlerContext context);
|
||||
Task HandleApplicationMessageAsync(MqttApplicationMessageReceivedEventArgs eventArgs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace MQTTnet.Client.Receiving
|
||||
{
|
||||
public class MqttApplicationMessageHandlerContext
|
||||
{
|
||||
public MqttApplicationMessageHandlerContext(string senderClientId, MqttApplicationMessage applicationMessage)
|
||||
{
|
||||
SenderClientId = senderClientId;
|
||||
ApplicationMessage = applicationMessage;
|
||||
}
|
||||
|
||||
public string SenderClientId { get; }
|
||||
|
||||
public MqttApplicationMessage ApplicationMessage { get; }
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,9 @@ namespace MQTTnet.Client.Receiving
|
||||
{
|
||||
public class MqttApplicationMessageHandlerDelegate : IMqttApplicationMessageHandler
|
||||
{
|
||||
private readonly Func<MqttApplicationMessageHandlerContext, Task> _handler;
|
||||
private readonly Func<MqttApplicationMessageReceivedEventArgs, Task> _handler;
|
||||
|
||||
public MqttApplicationMessageHandlerDelegate(Action<MqttApplicationMessageHandlerContext> handler)
|
||||
public MqttApplicationMessageHandlerDelegate(Action<MqttApplicationMessageReceivedEventArgs> handler)
|
||||
{
|
||||
if (handler == null) throw new ArgumentNullException(nameof(handler));
|
||||
|
||||
@@ -18,12 +18,12 @@ namespace MQTTnet.Client.Receiving
|
||||
};
|
||||
}
|
||||
|
||||
public MqttApplicationMessageHandlerDelegate(Func<MqttApplicationMessageHandlerContext, Task> handler)
|
||||
public MqttApplicationMessageHandlerDelegate(Func<MqttApplicationMessageReceivedEventArgs, Task> handler)
|
||||
{
|
||||
_handler = handler ?? throw new ArgumentNullException(nameof(handler));
|
||||
}
|
||||
|
||||
public Task HandleApplicationMessageAsync(MqttApplicationMessageHandlerContext context)
|
||||
public Task HandleApplicationMessageAsync(MqttApplicationMessageReceivedEventArgs context)
|
||||
{
|
||||
return _handler(context);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user