From 7af9cd0df821689a69fdcce117cf36e43dcb5aec Mon Sep 17 00:00:00 2001 From: Cody Larkin Date: Mon, 6 Apr 2026 20:48:57 -0400 Subject: [PATCH] Auto stash before merge of "main" and "origin/main" --- RelayClient/MainPage.xaml.cs | 29 +++++++++------------ RelayClient/Resources/Raw/wwwroot/index.css | 2 +- RelayClient/Resources/Raw/wwwroot/index.js | 17 +++++++----- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/RelayClient/MainPage.xaml.cs b/RelayClient/MainPage.xaml.cs index ec89dcc..5a9e2cb 100644 --- a/RelayClient/MainPage.xaml.cs +++ b/RelayClient/MainPage.xaml.cs @@ -479,15 +479,17 @@ public partial class MainPage : ContentPage public async Task AnswerCallback(RtcDescription answer) { - string json = JsonSerializer.Serialize(answer); - SafeSendRawToWebView("WriteRtcAnswer answered with: " + json); + var test = new RtcDescription{type="answer", sdp = "Long\r\n string of data"}; + test.sdp = test.sdp.Replace("\r\n", "(rn)"); + // SafeSendRawToWebView("TEST: " + test); + answer.sdp = answer.sdp.Replace("\r\n", "(rn)"); + string json = JsonSerializer.Serialize(test, HybridJSType.Default.RtcDescription); + SafeSendRawToWebView("JSON: " + json); + try { - SafeSendRawToWebView("Pre"); - // await hybridWebView.InvokeJavaScriptAsync("CSharpCallTest", ["value from C#"], [HybridJSTypeString.Default.String]); - // SafeSendRawToWebView("Mid"); - await hybridWebView.InvokeJavaScriptAsync("AnswerCallback", [json], [HybridJSTypeString.Default.String]); - SafeSendRawToWebView("End"); + await hybridWebView.InvokeJavaScriptAsync("AnswerCallbackJS", [answer], [HybridJSType.Default.RtcDescription]); + SafeSendRawToWebView("After JS"); } catch (Exception ex) { @@ -582,16 +584,11 @@ public partial class MainPage : ContentPage }); } - [JsonSourceGenerationOptions(WriteIndented = true)] - [JsonSerializable(typeof(string))] - internal partial class HybridJSTypeString : JsonSerializerContext - { - // This type's attributes specify JSON serialization info to preserve type structure - // for trimmed builds. - } - [JsonSourceGenerationOptions(WriteIndented = true)] + [JsonSourceGenerationOptions(WriteIndented = false)] [JsonSerializable(typeof(RtcDescription))] - internal partial class HybridJSTypeRtcDescription : JsonSerializerContext + [JsonSerializable(typeof(List))] + [JsonSerializable(typeof(string))] + internal partial class HybridJSType : JsonSerializerContext { // This type's attributes specify JSON serialization info to preserve type structure // for trimmed builds. diff --git a/RelayClient/Resources/Raw/wwwroot/index.css b/RelayClient/Resources/Raw/wwwroot/index.css index bea7afa..005dc59 100644 --- a/RelayClient/Resources/Raw/wwwroot/index.css +++ b/RelayClient/Resources/Raw/wwwroot/index.css @@ -85,5 +85,5 @@ textarea::-webkit-scrollbar-thumb { background: #1F1A24; border: 1px solid #332940; border-radius: 10px; - padding: 11px; + padding: 12px; } \ No newline at end of file diff --git a/RelayClient/Resources/Raw/wwwroot/index.js b/RelayClient/Resources/Raw/wwwroot/index.js index 18c7760..9cae233 100644 --- a/RelayClient/Resources/Raw/wwwroot/index.js +++ b/RelayClient/Resources/Raw/wwwroot/index.js @@ -262,17 +262,22 @@ async function channelCallJoin(activeCall) async function CSharpCallTest(value) { LogMessage("Called from C#: " + value); + // let test = JSON.parse(value); + // LogMessage("JSON : " + JSON.stringify(test)); } -async function AnswerCallback(answer) +async function AnswerCallbackJS(answer) { - LogMessage("Answer: " + answer); + answer.sdp = answer.sdp.replaceAll("(rn)", "\r\n"); + // answer.sdp += "\n"; + LogMessage("Answer: " + JSON.stringify(answer)); - let callBack = JSON.parse(answer); - LogMessage("Call Back: " + callBack); + // let callBack = JSON.parse(answer); + // LogMessage("Call Back: " + callBack); + LogMessage("RemoteDescription: " + peerConnection.currentRemoteDescription); - if (!peerConnection.currentRemoteDescription && callBack) + if (!peerConnection.currentRemoteDescription && answer) { - LogMessage("Current answer: " + callBack); + LogMessage("Current answer: " + JSON.stringify(answer)); const desc = new RTCSessionDescription(answer); await peerConnection.setRemoteDescription(desc); }