Server refactoring

This commit is contained in:
Christian Kratky
2017-10-26 21:22:58 +02:00
parent f85721fbf5
commit d0f1c18a2f
20 changed files with 145 additions and 64 deletions
@@ -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;
}
}
}