Add Wiki Code.

This commit is contained in:
Christian Kratky
2019-05-06 20:22:41 +02:00
parent 2ecbd83d06
commit 53ab2ac140
2 changed files with 43 additions and 2 deletions
@@ -1,6 +1,8 @@
using System;
using System.Collections.Concurrent;
using System.Collections.ObjectModel;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using Windows.Security.Cryptography.Certificates;
@@ -595,7 +597,7 @@ namespace MQTTnet.TestApp.UniversalWindows
};
}
}
// ----------------------------------
{
var options = new MqttServerOptions();
@@ -714,6 +716,25 @@ namespace MQTTnet.TestApp.UniversalWindows
var mqttServer = new MqttFactory().CreateMqttServer();
}
{
// Setup subscription interceptor.
var options = new MqttServerOptionsBuilder()
.WithSubscriptionInterceptor(context =>
{
if (context.TopicFilter.Topic.StartsWith("admin/foo/bar") && context.ClientId != "theAdmin")
{
context.AcceptSubscription = false;
}
if (context.TopicFilter.Topic.StartsWith("the/secret/stuff") && context.ClientId != "Imperator")
{
context.AcceptSubscription = false;
context.CloseConnection = true;
}
})
.Build();
}
{
// Setup and start a managed MQTT client.
var options = new ManagedMqttClientOptionsBuilder()