mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-20 19:58:57 +08:00
Update Wiki samples.
This commit is contained in:
@@ -733,6 +733,22 @@ namespace MQTTnet.TestApp.UniversalWindows
|
|||||||
var mqttServer = new MqttFactory().CreateMqttServer();
|
var mqttServer = new MqttFactory().CreateMqttServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Setup application message interceptor.
|
||||||
|
var options = new MqttServerOptionsBuilder()
|
||||||
|
.WithApplicationMessageInterceptor(context =>
|
||||||
|
{
|
||||||
|
if (context.ApplicationMessage.Topic == "my/custom/topic")
|
||||||
|
{
|
||||||
|
context.ApplicationMessage.Payload = Encoding.UTF8.GetBytes("The server injected payload.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// It is also possible to read the payload and extend it. For example by adding a timestamp in a JSON document.
|
||||||
|
// This is useful when the IoT device has no own clock and the creation time of the message might be important.
|
||||||
|
})
|
||||||
|
.Build();
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Setup subscription interceptor.
|
// Setup subscription interceptor.
|
||||||
var options = new MqttServerOptionsBuilder()
|
var options = new MqttServerOptionsBuilder()
|
||||||
|
|||||||
Reference in New Issue
Block a user