Update documentation

This commit is contained in:
Christian Kratky
2017-11-09 00:03:22 +01:00
parent 1c78cd4c31
commit eaf27c1e12
5 changed files with 84 additions and 11 deletions
+19 -4
View File
@@ -35,14 +35,29 @@ namespace MQTTnet.TestApp.NetCore
options.Storage = new RetainedMessageHandler();
// Extend the timestamp for all messages from clients.
options.ApplicationMessageInterceptor = context =>
{
if (MqttTopicFilterComparer.IsMatch(context.ApplicationMessage.Topic, "/myTopic/WithTimestamp/#"))
{
// Replace the payload with the timestamp. But also extending a JSON
// based payload with the timestamp is a suitable use case.
context.ApplicationMessage.Payload = Encoding.UTF8.GetBytes(DateTime.Now.ToString("O"));
}
// Replace the payload with the timestamp. But also extending a JSON
// based payload with the timestamp is a suitable use case.
context.ApplicationMessage.Payload = Encoding.UTF8.GetBytes(DateTime.Now.ToString("O"));
}
};
// Protect several topics from being subscribed from every client.
options.SubscriptionsInterceptor = 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;
}
};
});