updated to shared lib
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
using WebSocketSharp;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.Json.Serialization.Metadata;
|
||||
using RelayShared.Rtc;
|
||||
|
||||
namespace RelayClient;
|
||||
@@ -82,7 +81,7 @@ public partial class MainPage : ContentPage
|
||||
var payload = new SocketEncryptedMessage
|
||||
{
|
||||
ChannelId = _currentChannelId!,
|
||||
Type = "client_encrypted_chat",
|
||||
Type = SignalType.ClientEncryptedChat,
|
||||
SenderUsername = _username,
|
||||
CipherText = encrypted.CipherText,
|
||||
Nonce = encrypted.Nonce,
|
||||
@@ -119,9 +118,9 @@ public partial class MainPage : ContentPage
|
||||
if (!root.TryGetProperty("Type", out var typeElement))
|
||||
return;
|
||||
|
||||
var type = typeElement.GetString();
|
||||
var type = (SignalType) typeElement.GetInt32();
|
||||
|
||||
if (type == "channel_list")
|
||||
if (type == SignalType.ChannelList)
|
||||
{
|
||||
var channelList = JsonSerializer.Deserialize<SocketChannelList>(e.Data);
|
||||
if (channelList is null)
|
||||
@@ -154,7 +153,7 @@ public partial class MainPage : ContentPage
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "server_public_key")
|
||||
if (type == SignalType.ServerPublicKey)
|
||||
{
|
||||
var serverKeyMessage = JsonSerializer.Deserialize<ServerPublicKeyMessage>(e.Data);
|
||||
if (serverKeyMessage is not null)
|
||||
@@ -166,7 +165,7 @@ public partial class MainPage : ContentPage
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "encrypted_rtc_signal")
|
||||
if (type == SignalType.EncryptedSignal)
|
||||
{
|
||||
var payload = JsonSerializer.Deserialize<SocketRtcSignalMessage>(e.Data);
|
||||
if (payload is null)
|
||||
@@ -199,13 +198,13 @@ public partial class MainPage : ContentPage
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "rtc_offer_updated" || type == "rtc_answer_updated" || type == "rtc_candidate_added" || type == "rtc_call_left")
|
||||
if (type == SignalType.OfferUpdated || type == SignalType.AnswerUpdated || type == SignalType.CandidateAdded || type == SignalType.CallLeft)
|
||||
{
|
||||
var rtcNotification = JsonSerializer.Deserialize<RtcNotificationMessage>(e.Data);
|
||||
if (rtcNotification is null)
|
||||
return;
|
||||
|
||||
var notificationType = rtcNotification.Type ?? string.Empty;
|
||||
var notificationType = rtcNotification.Type ?? null;
|
||||
var notificationChannelId = rtcNotification.ChannelId ?? string.Empty;
|
||||
|
||||
if (notificationChannelId != _currentChannelId)
|
||||
@@ -217,13 +216,13 @@ public partial class MainPage : ContentPage
|
||||
{
|
||||
switch (notificationType)
|
||||
{
|
||||
case "rtc_offer_updated":
|
||||
case SignalType.OfferUpdated :
|
||||
{
|
||||
var offer = await GetRtcOffer();
|
||||
await SendRtcSignalToJsAsync(offer);
|
||||
break;
|
||||
}
|
||||
case "rtc_answer_updated":
|
||||
case SignalType.AnswerUpdated:
|
||||
{
|
||||
var answer = await ServerAPI.GetAnswerForChannelAsync(_currentChannelId);
|
||||
if (answer is not null)
|
||||
@@ -232,7 +231,7 @@ public partial class MainPage : ContentPage
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "rtc_candidate_added":
|
||||
case SignalType.CandidateAdded:
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -246,7 +245,7 @@ public partial class MainPage : ContentPage
|
||||
|
||||
break;
|
||||
}
|
||||
case "rtc_call_left":
|
||||
case SignalType.CallLeft:
|
||||
{
|
||||
SafeSendRawToWebView("RTC call left notification received.");
|
||||
RtcLeaveCallback();
|
||||
@@ -258,7 +257,7 @@ public partial class MainPage : ContentPage
|
||||
return;
|
||||
}
|
||||
|
||||
if (type != "encrypted_chat")
|
||||
if (type != SignalType.EncryptedChat)
|
||||
return;
|
||||
|
||||
var pyload = JsonSerializer.Deserialize<SocketEncryptedMessage>(e.Data);
|
||||
@@ -429,7 +428,7 @@ public partial class MainPage : ContentPage
|
||||
|
||||
bool active = await ServerAPI.GetIsChannelActiveAsync(_currentChannelId);
|
||||
|
||||
// SafeSendRawToWebView($"Rtc Channel {_currentChannelName} | {_currentChannelId} is active: {active}");
|
||||
SafeSendRawToWebView($"Rtc Channel {_currentChannelName} | {_currentChannelId} is active: {active}");
|
||||
|
||||
return active;
|
||||
}
|
||||
@@ -588,7 +587,7 @@ public partial class MainPage : ContentPage
|
||||
|
||||
var payload = new SocketRtcSignalMessage
|
||||
{
|
||||
Type = "encrypted_rtc_signal",
|
||||
Type = SignalType.EncryptedSignal,
|
||||
SenderUsername = _username,
|
||||
ChannelId = rtcSignal.ChannelId,
|
||||
CipherText = encrypted.CipherText,
|
||||
|
||||
Reference in New Issue
Block a user