mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-26 16:24:10 +08:00
Refactoring
This commit is contained in:
@@ -9,6 +9,7 @@ using Microsoft.Extensions.Logging;
|
||||
using MQTTnet.Core;
|
||||
using MQTTnet.Core.Client;
|
||||
using MQTTnet.Core.Diagnostics;
|
||||
using MQTTnet.Core.ManagedClient;
|
||||
using MQTTnet.Core.Protocol;
|
||||
using MQTTnet.Core.Server;
|
||||
using MQTTnet.Implementations;
|
||||
@@ -454,6 +455,21 @@ namespace MQTTnet.TestApp.UniversalWindows
|
||||
var mqttServer = new MqttFactory().CreateMqttServer();
|
||||
}
|
||||
|
||||
{
|
||||
// Setup and start a managed MQTT client.
|
||||
var options = new ManagedMqttClientOptionsBuilder()
|
||||
.WithAutoReconnectDelay(TimeSpan.FromSeconds(5))
|
||||
.WithClientOptions(new MqttClientOptionsBuilder()
|
||||
.WithClientId("Client1")
|
||||
.WithTcpServer("broker.hivemq.com")
|
||||
.WithTls().Build())
|
||||
.Build();
|
||||
|
||||
var mqttClient = new MqttFactory().CreateManagedMqttClient();
|
||||
await mqttClient.SubscribeAsync(new TopicFilterBuilder().WithTopic("my/topic").Build());
|
||||
await mqttClient.StartAsync(options);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private async void StartServer(object sender, RoutedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user