mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-19 11:03:07 +08:00
Refactor serializer locking and thread instances.
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:server="using:MQTTnet.Server"
|
||||
xmlns:interop="using:Windows.UI.Xaml.Interop"
|
||||
d:DesignHeight="800"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
@@ -31,7 +33,7 @@
|
||||
<CheckBox x:Name="CleanSession" IsChecked="True"></CheckBox>
|
||||
<TextBlock>Keep alive interval:</TextBlock>
|
||||
<TextBox x:Name="KeepAliveInterval" Text="5"></TextBox>
|
||||
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<RadioButton x:Name="UseTcp" IsChecked="True" GroupName="connection">TCP</RadioButton>
|
||||
<RadioButton x:Name="UseWs" GroupName="connection">WS</RadioButton>
|
||||
@@ -142,6 +144,7 @@
|
||||
|
||||
<CheckBox x:Name="ServerPersistRetainedMessages" IsChecked="True">Persist retained messages in JSON format</CheckBox>
|
||||
<CheckBox x:Name="ServerClearRetainedMessages">Clear previously retained messages on startup</CheckBox>
|
||||
<CheckBox x:Name="ServerAllowPersistentSessions">Allow persistent sessions</CheckBox>
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Width="120" Margin="0,0,10,0" Click="StartServer">Start</Button>
|
||||
@@ -149,11 +152,6 @@
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</PivotItem>
|
||||
<PivotItem Header="Log">
|
||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Button Click="ClearLog" Width="120">Clear</Button>
|
||||
</StackPanel>
|
||||
</PivotItem>
|
||||
|
||||
<PivotItem Header="Sessions">
|
||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
@@ -162,12 +160,23 @@
|
||||
<Button Width="120" Margin="0,0,10,0" Click="ClearSessions">Clear</Button>
|
||||
</StackPanel>
|
||||
|
||||
<ListView>
|
||||
<ListView ItemsSource="{Binding}" x:Name="ListViewSessions">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<TextBlock></TextBlock>
|
||||
</Grid>
|
||||
<DataTemplate x:DataType="server:IMqttClientSessionStatus">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Margin" Value="0,0,10,0"></Setter>
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<TextBlock Text="{Binding ClientId}"></TextBlock>
|
||||
<TextBlock Text="{Binding Endpoint}"></TextBlock>
|
||||
<TextBlock Text="{Binding IsConnected}"></TextBlock>
|
||||
<TextBlock Text="{Binding LastPacketReceived}"></TextBlock>
|
||||
<TextBlock Text="{Binding LastNonKeepAlivePacketReceived}"></TextBlock>
|
||||
<TextBlock Text="{Binding ProtocolVersion}"></TextBlock>
|
||||
<TextBlock Text="{Binding PendingApplicationMessagesCount}"></TextBlock>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Security.Cryptography.Certificates;
|
||||
@@ -21,6 +22,7 @@ namespace MQTTnet.TestApp.UniversalWindows
|
||||
public sealed partial class MainPage
|
||||
{
|
||||
private readonly ConcurrentQueue<MqttNetLogMessage> _traceMessages = new ConcurrentQueue<MqttNetLogMessage>();
|
||||
private readonly ObservableCollection<IMqttClientSessionStatus> _sessions = new ObservableCollection<IMqttClientSessionStatus>();
|
||||
|
||||
private IMqttClient _mqttClient;
|
||||
private IMqttServer _mqttServer;
|
||||
@@ -306,6 +308,7 @@ namespace MQTTnet.TestApp.UniversalWindows
|
||||
var options = new MqttServerOptions();
|
||||
options.DefaultEndpointOptions.Port = int.Parse(ServerPort.Text);
|
||||
options.Storage = storage;
|
||||
options.EnablePersistentSessions = ServerAllowPersistentSessions.IsChecked == true;
|
||||
|
||||
await _mqttServer.StartAsync(options);
|
||||
}
|
||||
@@ -374,10 +377,25 @@ namespace MQTTnet.TestApp.UniversalWindows
|
||||
|
||||
private void ClearSessions(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_sessions.Clear();
|
||||
}
|
||||
|
||||
private void RefreshSessions(object sender, RoutedEventArgs e)
|
||||
private async void RefreshSessions(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_mqttServer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var sessions = await _mqttServer.GetClientSessionsStatusAsync();
|
||||
_sessions.Clear();
|
||||
|
||||
foreach (var session in sessions)
|
||||
{
|
||||
_sessions.Add(session);
|
||||
}
|
||||
|
||||
ListViewSessions.DataContext = _sessions;
|
||||
}
|
||||
|
||||
private async Task WikiCode()
|
||||
|
||||
Reference in New Issue
Block a user