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