Server termination and refactoring message dialogs.

This commit is contained in:
Burak Kaan Köse
2024-08-21 22:42:52 +02:00
parent bab3272970
commit f627226da9
31 changed files with 548 additions and 388 deletions

View File

@@ -2,6 +2,7 @@
using System.Diagnostics;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows;
using CommunityToolkit.Mvvm.Messaging;
using Serilog;
using Windows.ApplicationModel;
@@ -308,12 +309,28 @@ namespace Wino.Server
case nameof(ServerTerminationModeChanged):
await ExecuteServerMessageSafeAsync(args, JsonSerializer.Deserialize<ServerTerminationModeChanged>(messageJson, _jsonSerializerOptions));
break;
case nameof(TerminateServerRequested):
await ExecuteServerMessageSafeAsync(args, JsonSerializer.Deserialize<TerminateServerRequested>(messageJson, _jsonSerializerOptions));
KillServer();
break;
default:
Debug.WriteLine($"Missing handler for {typeName} in the server. Check ServerContext.cs - HandleServerMessageAsync.");
break;
}
}
private void KillServer()
{
DisposeConnection();
Application.Current.Dispatcher.Invoke(() =>
{
Application.Current.Shutdown();
});
}
/// <summary>
/// Executes ServerMessage coming from the UWP.
/// These requests are awaited and expected to return a response.