Refactor interceptors etc. to support async.

This commit is contained in:
Christian Kratky
2018-12-27 22:41:41 +01:00
parent 38f2453c92
commit c0507fcc55
33 changed files with 537 additions and 311 deletions
+7 -6
View File
@@ -23,7 +23,7 @@ namespace MQTTnet.TestApp.NetCore
{
var options = new MqttServerOptions
{
ConnectionValidator = p =>
ConnectionValidator = new MqttServerConnectionValidatorDelegate(p =>
{
if (p.ClientId == "SpecialClient")
{
@@ -32,11 +32,11 @@ namespace MQTTnet.TestApp.NetCore
p.ReturnCode = MqttConnectReturnCode.ConnectionRefusedBadUsernameOrPassword;
}
}
},
}),
Storage = new RetainedMessageHandler(),
ApplicationMessageInterceptor = context =>
ApplicationMessageInterceptor = new MqttServerApplicationMessageInterceptorDelegate(context =>
{
if (MqttTopicFilterComparer.IsMatch(context.ApplicationMessage.Topic, "/myTopic/WithTimestamp/#"))
{
@@ -50,8 +50,9 @@ namespace MQTTnet.TestApp.NetCore
context.AcceptPublish = false;
context.CloseConnection = true;
}
},
SubscriptionInterceptor = context =>
}),
SubscriptionInterceptor = new MqttServerSubscriptionInterceptorDelegate(context =>
{
if (context.TopicFilter.Topic.StartsWith("admin/foo/bar") && context.ClientId != "theAdmin")
{
@@ -63,7 +64,7 @@ namespace MQTTnet.TestApp.NetCore
context.AcceptSubscription = false;
context.CloseConnection = true;
}
}
})
};
// Extend the timestamp for all messages from clients.