mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-20 11:45:43 +08:00
Server refactoring
This commit is contained in:
@@ -9,6 +9,7 @@ using MQTTnet.Core;
|
||||
using MQTTnet.Core.Client;
|
||||
using MQTTnet.Core.Diagnostics;
|
||||
using MQTTnet.Core.Protocol;
|
||||
using MQTTnet.Core.Server;
|
||||
using MQTTnet.Implementations;
|
||||
|
||||
namespace MQTTnet.TestApp.UniversalWindows
|
||||
@@ -16,6 +17,7 @@ namespace MQTTnet.TestApp.UniversalWindows
|
||||
public sealed partial class MainPage
|
||||
{
|
||||
private IMqttClient _mqttClient;
|
||||
private IMqttServer _mqttServer;
|
||||
|
||||
public MainPage()
|
||||
{
|
||||
@@ -319,5 +321,27 @@ namespace MQTTnet.TestApp.UniversalWindows
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private async void StartServer(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_mqttServer != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_mqttServer = new MqttFactory().CreateMqttServer();
|
||||
await _mqttServer.StartAsync();
|
||||
}
|
||||
|
||||
private async void StopServer(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_mqttServer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await _mqttServer.StopAsync();
|
||||
_mqttServer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user