feat: add safe Tornado K3D playout adapter
This commit is contained in:
@@ -27,6 +27,7 @@ public sealed partial class MainWindow : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializeDatabaseRuntime();
|
||||
InitializePlayoutRuntime();
|
||||
Root.Loaded += OnRootLoaded;
|
||||
Closed += OnClosed;
|
||||
}
|
||||
@@ -60,6 +61,7 @@ public sealed partial class MainWindow : Window
|
||||
if (_webViewReady)
|
||||
{
|
||||
_ = MonitorDatabaseHealthAsync(_lifetimeCancellation.Token);
|
||||
_ = ConnectPlayoutAsync(_lifetimeCancellation.Token);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +126,9 @@ public sealed partial class MainWindow : Window
|
||||
return;
|
||||
}
|
||||
|
||||
if (uri.Host.Equals(AppHost, StringComparison.OrdinalIgnoreCase) || uri.Scheme == "about")
|
||||
if ((uri.Scheme == Uri.UriSchemeHttps &&
|
||||
uri.Host.Equals(AppHost, StringComparison.OrdinalIgnoreCase)) ||
|
||||
uri.Scheme == "about")
|
||||
{
|
||||
LoadingOverlay.Visibility = Visibility.Visible;
|
||||
return;
|
||||
@@ -162,6 +166,13 @@ public sealed partial class MainWindow : Window
|
||||
|
||||
private void OnWebMessageReceived(object? sender, CoreWebView2WebMessageReceivedEventArgs args)
|
||||
{
|
||||
if (!Uri.TryCreate(args.Source, UriKind.Absolute, out var source) ||
|
||||
source.Scheme != Uri.UriSchemeHttps ||
|
||||
!source.Host.Equals(AppHost, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var request = JsonSerializer.Deserialize<WebRequest>(args.WebMessageAsJson, JsonOptions);
|
||||
@@ -172,10 +183,17 @@ public sealed partial class MainWindow : Window
|
||||
case "request-app-info":
|
||||
PostAppInfo();
|
||||
_ = PostDatabaseStatusAsync(_lifetimeCancellation.Token);
|
||||
PostPlayoutStatus();
|
||||
break;
|
||||
case "request-database-status":
|
||||
_ = PostDatabaseStatusAsync(_lifetimeCancellation.Token);
|
||||
break;
|
||||
case "request-playout-status":
|
||||
HandlePlayoutStatusRequest(request.Payload);
|
||||
break;
|
||||
case "playout-command":
|
||||
_ = HandlePlayoutCommandAsync(request.Payload);
|
||||
break;
|
||||
case "request-market-data" when request.Payload.ValueKind == JsonValueKind.Object:
|
||||
_ = HandleMarketDataRequestAsync(request.Payload);
|
||||
break;
|
||||
@@ -501,6 +519,7 @@ public sealed partial class MainWindow : Window
|
||||
var wasWebViewReady = _webViewReady;
|
||||
_webViewReady = false;
|
||||
_lifetimeCancellation.Cancel();
|
||||
ShutdownPlayoutRuntime();
|
||||
var requestCancellation = Interlocked.Exchange(ref _marketDataCancellation, null);
|
||||
requestCancellation?.Cancel();
|
||||
requestCancellation?.Dispose();
|
||||
|
||||
Reference in New Issue
Block a user