Compare commits
2 Commits
a2608ffab9
...
3b75c2b785
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b75c2b785 | |||
| 4f6bbcf6e2 |
@@ -106,7 +106,7 @@ public partial class MainPage : ContentPage
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SafeSendRawToWebView($"[{_username}] RAW WS DATA: {e.Data}");
|
// SafeSendRawToWebView($"[{_username}] RAW WS DATA: {e.Data}");
|
||||||
|
|
||||||
Console.WriteLine($"[{_username}] RAW WS DATA: {e.Data}");
|
Console.WriteLine($"[{_username}] RAW WS DATA: {e.Data}");
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ public partial class MainPage : ContentPage
|
|||||||
if (notificationChannelId != _currentChannelId)
|
if (notificationChannelId != _currentChannelId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SafeSendRawToWebView("RTC notification received: " + notificationType + " for " + notificationChannelId);
|
// SafeSendRawToWebView("RTC notification received: " + notificationType + " for " + notificationChannelId);
|
||||||
|
|
||||||
MainThread.BeginInvokeOnMainThread(async () =>
|
MainThread.BeginInvokeOnMainThread(async () =>
|
||||||
{
|
{
|
||||||
@@ -434,7 +434,7 @@ public partial class MainPage : ContentPage
|
|||||||
|
|
||||||
_wsc.Send($"RTC_JOIN_CHANNEL|{_username}|{_currentChannelId}");
|
_wsc.Send($"RTC_JOIN_CHANNEL|{_username}|{_currentChannelId}");
|
||||||
|
|
||||||
SafeSendRawToWebView($"Attempting to join RTC Channel {_currentChannelName} | {_currentChannelId} ");
|
// SafeSendRawToWebView($"Attempting to join RTC Channel {_currentChannelName} | {_currentChannelId} ");
|
||||||
|
|
||||||
bool active = await ServerAPI.GetIsChannelActiveAsync(_currentChannelId);
|
bool active = await ServerAPI.GetIsChannelActiveAsync(_currentChannelId);
|
||||||
|
|
||||||
@@ -462,11 +462,12 @@ public partial class MainPage : ContentPage
|
|||||||
Username = _username,
|
Username = _username,
|
||||||
SessionDescription = description
|
SessionDescription = description
|
||||||
};
|
};
|
||||||
await ServerAPI.PostOfferAsync(offer);
|
var response = await ServerAPI.PostOfferAsync(offer);
|
||||||
|
SafeSendRawToWebView(response.ToString());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
SafeSendRawToWebView(ex.Message);
|
SafeSendRawToWebView($"WriteRtcOffer failed: {ex.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,13 +161,21 @@ async function joinChannelCall() {
|
|||||||
LogMessage("Current username: " + currentUsername);
|
LogMessage("Current username: " + currentUsername);
|
||||||
LogMessage("Current channel: " + currentChannelId);
|
LogMessage("Current channel: " + currentChannelId);
|
||||||
|
|
||||||
await window.HybridWebView.InvokeDotNet("JoinRtcChannel");
|
const isActive = await window.HybridWebView.InvokeDotNet("JoinRtcChannel");
|
||||||
|
const peerConnection = await ensurePeerConnectionForUser(currentUsername);
|
||||||
await ensureLocalMedia();
|
await ensureLocalMedia();
|
||||||
|
|
||||||
|
if (isActive) {
|
||||||
|
|
||||||
|
const rawJson = await window.HybridWebView.InvokeDotNet("GetRtcOffer");
|
||||||
|
const offer = typeof rawJson === "string" ? JSON.parse(rawJson) : rawJson;
|
||||||
|
await peerConnection.setRemoteDescription(offer);
|
||||||
|
const answer = await peerConnection.createAnswer();
|
||||||
|
await peerConnection.setRemoteDescription(answer);
|
||||||
|
await window.HybridWebView.InvokeDotNet("WriteRtcAnswer", [JSON.stringify(answer)])
|
||||||
|
|
||||||
const rawParticipants = await window.HybridWebView.InvokeDotNet("GetRtcParticipants");
|
const rawParticipants = await window.HybridWebView.InvokeDotNet("GetRtcParticipants");
|
||||||
const participants = typeof rawParticipants === "string"
|
const participants = typeof rawParticipants === "string" ? JSON.parse(rawParticipants) : rawParticipants;
|
||||||
? JSON.parse(rawParticipants)
|
|
||||||
: rawParticipants;
|
|
||||||
|
|
||||||
LogMessage("Participants: " + JSON.stringify(participants)); // TODO: Remove
|
LogMessage("Participants: " + JSON.stringify(participants)); // TODO: Remove
|
||||||
|
|
||||||
@@ -191,7 +199,43 @@ async function joinChannelCall() {
|
|||||||
LogMessage(`Sent offer to ${username}`);
|
LogMessage(`Sent offer to ${username}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
LogMessage(currentUsername + " attempted to join inactive channel. Making new call.")
|
||||||
|
const offer = await peerConnection.createOffer();
|
||||||
|
await peerConnection.setLocalDescription(offer);
|
||||||
|
await window.HybridWebView.InvokeDotNet("WriteRtcOffer", [JSON.stringify(offer)]);
|
||||||
|
LogMessage(`Joining call with media offer: ${JSON.stringify(offer)}`);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
LogMessage(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function channelCallJoin(activeCall)
|
||||||
|
{
|
||||||
|
// LogMessage("Active call: " + activeCall);
|
||||||
|
await ensurePeerConnectionForUser(currentUsername);
|
||||||
|
|
||||||
|
if (activeCall)
|
||||||
|
{
|
||||||
|
const rawJson = await window.HybridWebView.InvokeDotNet("GetRtcOffer");
|
||||||
|
const offer = typeof rawJson === "string" ? JSON.parse(rawJson) : rawJson;
|
||||||
|
await peerConnection.setRemoteDescription(offer);
|
||||||
|
const answer = await peerConnection.createAnswer();
|
||||||
|
await peerConnection.setLocalDescription(answer);
|
||||||
|
// LogMessage("Joining call with media answer: " + JSON.stringify(answer));
|
||||||
|
// LogMessage("Calling C# WriteRtcAnswer with: " + JSON.stringify(answer));
|
||||||
|
await window.HybridWebView.InvokeDotNet("WriteRtcAnswer", [JSON.stringify(answer)]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const offer = await peerConnection.createOffer();
|
||||||
|
await peerConnection.setLocalDescription(offer);
|
||||||
|
await window.HybridWebView.InvokeDotNet("WriteRtcOffer", [JSON.stringify(offer)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
async function ensurePeerConnectionForUser(username) {
|
async function ensurePeerConnectionForUser(username) {
|
||||||
if (peerConnections[username]) return peerConnections[username];
|
if (peerConnections[username]) return peerConnections[username];
|
||||||
|
|
||||||
|
|||||||
@@ -64,18 +64,18 @@ Start-Sleep -Seconds 5
|
|||||||
& '$clientExe' --user Ru_Kira
|
& '$clientExe' --user Ru_Kira
|
||||||
"@
|
"@
|
||||||
|
|
||||||
# $testScript = New-TabScript -Name "Test" -Content @"
|
$testScript = New-TabScript -Name "Test" -Content @"
|
||||||
# Set-Location '$root'
|
Set-Location '$root'
|
||||||
# Start-Sleep -Seconds 25
|
Start-Sleep -Seconds 25
|
||||||
# & '$clientExe' --user Test
|
& '$clientExe' --user Test
|
||||||
# "@
|
"@
|
||||||
|
|
||||||
$wtArgs = @(
|
$wtArgs = @(
|
||||||
"new-tab --title `"SurrealDB`" `"$ps`" -NoExit -ExecutionPolicy Bypass -File `"$dockerScript`"",
|
"new-tab --title `"SurrealDB`" `"$ps`" -NoExit -ExecutionPolicy Bypass -File `"$dockerScript`"",
|
||||||
"new-tab --title `"RelayCore`" `"$ps`" -NoExit -ExecutionPolicy Bypass -File `"$coreScript`"",
|
"new-tab --title `"RelayCore`" `"$ps`" -NoExit -ExecutionPolicy Bypass -File `"$coreScript`"",
|
||||||
"new-tab --title `"RelayServer`" `"$ps`" -NoExit -ExecutionPolicy Bypass -File `"$serverScript`"",
|
"new-tab --title `"RelayServer`" `"$ps`" -NoExit -ExecutionPolicy Bypass -File `"$serverScript`"",
|
||||||
"new-tab --title `"Keeper317`" `"$ps`" -NoExit -ExecutionPolicy Bypass -File `"$keeperScript`"",
|
"new-tab --title `"Keeper317`" `"$ps`" -NoExit -ExecutionPolicy Bypass -File `"$keeperScript`"",
|
||||||
# "new-tab --title `"Test`" `"$ps`" -NoExit -ExecutionPolicy Bypass -File `"$testScript`"",
|
"new-tab --title `"Test`" `"$ps`" -NoExit -ExecutionPolicy Bypass -File `"$testScript`"",
|
||||||
"new-tab --title `"Ru_Kira`" `"$ps`" -NoExit -ExecutionPolicy Bypass -File `"$kiraScript`""
|
"new-tab --title `"Ru_Kira`" `"$ps`" -NoExit -ExecutionPolicy Bypass -File `"$kiraScript`""
|
||||||
) -join " ; "
|
) -join " ; "
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user