Fixed connections
This commit is contained in:
@@ -118,7 +118,7 @@ public sealed class RtcBridgeService
|
||||
|
||||
public async Task HandleIncomingRtcSignalAsync(SocketRtcSignalMessage payload)
|
||||
{
|
||||
_sendRawToWebView("HandleIncomingRtcSignal called");
|
||||
// _sendRawToWebView("HandleIncomingRtcSignal called");
|
||||
var currentChannelId = _getCurrentChannelId();
|
||||
|
||||
if (payload.ChannelId != currentChannelId)
|
||||
@@ -134,7 +134,7 @@ public sealed class RtcBridgeService
|
||||
}
|
||||
|
||||
string decryptedJson;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var privateKey = KeyStorage.LoadPrivateKey(_username);
|
||||
@@ -170,7 +170,10 @@ public sealed class RtcBridgeService
|
||||
}
|
||||
|
||||
if (rtcSignal is null)
|
||||
{
|
||||
_sendRawToWebView("rtcSignal is null");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(rtcSignal.To) &&
|
||||
!string.Equals(rtcSignal.To, _username, StringComparison.OrdinalIgnoreCase))
|
||||
@@ -200,37 +203,42 @@ public sealed class RtcBridgeService
|
||||
|
||||
private Task SendRtcSignalToJsAsync(RtcSignalMessage data)
|
||||
{
|
||||
if (data.Type == "rtc_offer" || data.Type == "rtc_answer")
|
||||
{
|
||||
data.Sdp = data.Sdp.Replace("\r\n", "(rn)");
|
||||
}
|
||||
MainThread.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
// await _hybridWebView.InvokeJavaScriptAsync("testIndex", [JsonSerializer.Serialize(data)], [RtcJsType.Default.String]);
|
||||
await _hybridWebView.InvokeJavaScriptAsync("testIndex", [data], [RtcJsType.Default.RtcSignalMessage]);
|
||||
var jsArg = JsonSerializer.Serialize(data);
|
||||
|
||||
await _hybridWebView.EvaluateJavaScriptAsync($@"
|
||||
try {{
|
||||
window.HybridWebView.SendRawMessage('C# eval entered');
|
||||
|
||||
if (!window.RelaySocket) {{
|
||||
window.HybridWebView.SendRawMessage('window.RelaySocket missing');
|
||||
}} else if (typeof window.RelaySocket.receiveRtcSignal !== 'function') {{
|
||||
window.HybridWebView.SendRawMessage('RelaySocket.receiveRtcSignal missing');
|
||||
}} else {{
|
||||
window.HybridWebView.SendRawMessage('Calling RelaySocket.receiveRtcSignal');
|
||||
window.RelaySocket.receiveRtcSignal({jsArg});
|
||||
}}
|
||||
}} catch (err) {{
|
||||
window.HybridWebView.SendRawMessage('RTC JS dispatch failed: ' + err);
|
||||
}}
|
||||
");
|
||||
#region OldDebugger
|
||||
// var jsArg = JsonSerializer.Serialize(data);
|
||||
//
|
||||
// await _hybridWebView.EvaluateJavaScriptAsync($@"
|
||||
// try {{
|
||||
// window.HybridWebView.SendRawMessage('C# eval entered');
|
||||
//
|
||||
// if (!window.RelaySocket) {{
|
||||
// window.HybridWebView.SendRawMessage('window.RelaySocket missing');
|
||||
// }} else if (typeof window.RelaySocket.receiveRtcSignal !== 'function') {{
|
||||
// window.HybridWebView.SendRawMessage('RelaySocket.receiveRtcSignal missing');
|
||||
// }} else {{
|
||||
// window.HybridWebView.SendRawMessage('Calling RelaySocket.receiveRtcSignal');
|
||||
// window.RelaySocket.receiveRtcSignal({jsArg});
|
||||
// }}
|
||||
// }} catch (err) {{
|
||||
// window.HybridWebView.SendRawMessage('RTC JS dispatch failed: ' + err);
|
||||
// }}
|
||||
// ");
|
||||
#endregion
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_sendRawToWebView("SendRtcSignalToJsAsync failed: " + ex.Message);
|
||||
}
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user