Update: Channel Based VC (Same Issues)
This commit is contained in:
@@ -136,10 +136,11 @@ public partial class MainPage : ContentPage
|
||||
_currentChannelId = defaultChannel.ChannelId;
|
||||
_currentChannelName = defaultChannel.Name;
|
||||
|
||||
MainThread.BeginInvokeOnMainThread(() =>
|
||||
MainThread.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
ChannelLabel.Text = $"#{_currentChannelName}";
|
||||
RenderChannelList();
|
||||
await PushRtcContextToJsAsync();
|
||||
});
|
||||
|
||||
_wsc.Send($"GET_HISTORY|{_username}|{_currentChannelId}");
|
||||
@@ -166,7 +167,10 @@ public partial class MainPage : ContentPage
|
||||
if (payload is null)
|
||||
return;
|
||||
|
||||
if (payload.RecipientUsername != _username)
|
||||
if (payload.ChannelId != _currentChannelId)
|
||||
return;
|
||||
|
||||
if (payload.SenderUsername == _username)
|
||||
return;
|
||||
|
||||
var privateKey = KeyStorage.LoadPrivateKey(_username);
|
||||
@@ -189,7 +193,7 @@ public partial class MainPage : ContentPage
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (type != "encrypted_chat")
|
||||
return;
|
||||
|
||||
@@ -267,6 +271,11 @@ public partial class MainPage : ContentPage
|
||||
{
|
||||
_currentChannelId = channel.ChannelId;
|
||||
_currentChannelName = channel.Name;
|
||||
|
||||
MainThread.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
await PushRtcContextToJsAsync();
|
||||
});
|
||||
|
||||
ChannelLabel.Text = $"#{_currentChannelName}";
|
||||
RenderCurrentChannelMessages();
|
||||
@@ -353,7 +362,7 @@ public partial class MainPage : ContentPage
|
||||
{
|
||||
if (e.Message == "rtc_page_ready")
|
||||
{
|
||||
await InitializeRtcPageAsync();
|
||||
await PushRtcContextToJsAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -388,7 +397,7 @@ public partial class MainPage : ContentPage
|
||||
{
|
||||
Type = "encrypted_rtc_signal",
|
||||
SenderUsername = _username,
|
||||
RecipientUsername = rtcSignal.To,
|
||||
ChannelId = rtcSignal.ChannelId,
|
||||
CipherText = encrypted.CipherText,
|
||||
Nonce = encrypted.Nonce,
|
||||
Tag = encrypted.Tag,
|
||||
@@ -396,7 +405,7 @@ public partial class MainPage : ContentPage
|
||||
};
|
||||
|
||||
_wsc.Send(JsonSerializer.Serialize(payload));
|
||||
Console.WriteLine($"[{_username}] sent RTC signal: {rtcSignal.Type} -> {rtcSignal.To}");
|
||||
Console.WriteLine($"[{_username}] sent RTC signal: {rtcSignal.Type} -> {rtcSignal.ChannelId}");
|
||||
}
|
||||
|
||||
private async Task SendRtcSignalToJsAsync(string rawJson)
|
||||
@@ -405,10 +414,14 @@ public partial class MainPage : ContentPage
|
||||
await hybridWebView.EvaluateJavaScriptAsync($"window.handleRtcSignal({jsArg})");
|
||||
}
|
||||
|
||||
private async Task InitializeRtcPageAsync()
|
||||
private async Task PushRtcContextToJsAsync()
|
||||
{
|
||||
var usernameJson = JsonSerializer.Serialize(_username);
|
||||
var channelIdJson = JsonSerializer.Serialize(_currentChannelId);
|
||||
|
||||
await hybridWebView.EvaluateJavaScriptAsync($"window.setUsername({usernameJson})");
|
||||
Console.WriteLine($"[{_username}] pushed username into HybridWebView.");
|
||||
await hybridWebView.EvaluateJavaScriptAsync($"window.setChannelId({channelIdJson})");
|
||||
|
||||
Console.WriteLine($"[{_username}] pushed RTC context into HybridWebView.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user