diff --git a/RelayClient/MainPage.xaml.cs b/RelayClient/MainPage.xaml.cs index 69a03cd..2f8d1c6 100644 --- a/RelayClient/MainPage.xaml.cs +++ b/RelayClient/MainPage.xaml.cs @@ -335,9 +335,11 @@ public partial class MainPage : ContentPage foreach (var channel in _channels.OrderBy(c => c.CreatedAt)) { - var button = new Button + var button = new ChannelButton { - Text = $"#{channel.Name}" + Text = $"#{channel.Name}", + Type = channel.Type, + Group = channel.Group }; button.Clicked += (_, _) => @@ -348,6 +350,11 @@ public partial class MainPage : ContentPage MainThread.BeginInvokeOnMainThread(async () => { await PushRtcContextToJsAsync(); + if (channel.Type == ChannelType.Voice) + { + SwapView(); + // JoinRtcChannel(); //TODO: Join voice calls when clicking channel rather than a separate button + } }); ChannelLabel.Text = $"#{_currentChannelName}"; @@ -409,7 +416,7 @@ public partial class MainPage : ContentPage await MessagesScrollView.ScrollToAsync(MessagesLayout, ScrollToPosition.End, true); } - private void SwapView_OnClicked(object? sender, EventArgs e) + private void SwapView() { if (RtcView.IsVisible) { @@ -425,6 +432,10 @@ public partial class MainPage : ContentPage ViewSwapped.Text = "Swap to Message View"; } } + private void SwapView_OnClicked(object? sender, EventArgs e) + { + SwapView(); + } #region RTC Functions public async Task JoinRtcChannel() @@ -648,6 +659,12 @@ public partial class MainPage : ContentPage } }); } + + public class ChannelButton : Button + { + public ChannelType Type { get; set; } + public string Group { get; set; } + } [JsonSourceGenerationOptions(WriteIndented = false)] [JsonSerializable(typeof(RtcDescription))] diff --git a/RelayClient/Resources/Raw/wwwroot/index.js b/RelayClient/Resources/Raw/wwwroot/index.js index e153dd5..d720498 100644 --- a/RelayClient/Resources/Raw/wwwroot/index.js +++ b/RelayClient/Resources/Raw/wwwroot/index.js @@ -157,6 +157,9 @@ async function refreshDevicesAndPreview() { } } +//TODO: Only join call if no active call in progress for client +//TODO: Enable proper leave call functions +//TODO: Leave call and join new call if client clicks a 2nd voice channel async function joinChannelCall() { LogMessage("Current username: " + currentUsername); LogMessage("Current channel: " + currentChannelId); diff --git a/RelayServer/Program.cs b/RelayServer/Program.cs index acdcc4c..24da678 100644 --- a/RelayServer/Program.cs +++ b/RelayServer/Program.cs @@ -34,8 +34,6 @@ var wssv = new WebSocketServer("ws://localhost:1337"); wssv.AddWebSocketService("/"); RtcNotificationService.Server = wssv; -//TODO: Use AnswerCallback as a test on client and use the /rtc/answer endpoint call as a test on server - wssv.Start(); Console.WriteLine("WebSocket server started"); diff --git a/RelayServer/Services/Chat/ChatSocketBehavior.cs b/RelayServer/Services/Chat/ChatSocketBehavior.cs index becc9d2..bdb4abb 100644 --- a/RelayServer/Services/Chat/ChatSocketBehavior.cs +++ b/RelayServer/Services/Chat/ChatSocketBehavior.cs @@ -206,7 +206,7 @@ public class ChatSocketBehavior : WebSocketBehavior Console.WriteLine("Db is not initialized."); return; } - + //TODO: Update to include ChannelType and Group String on channels var channels = GetChannelsSync() .OrderBy(c => c.CreatedAt) .Select(c => new ChannelItem() diff --git a/RelayShared/Rtc/RtcModels.cs b/RelayShared/Rtc/RtcModels.cs index eb52cc4..6f2de64 100644 --- a/RelayShared/Rtc/RtcModels.cs +++ b/RelayShared/Rtc/RtcModels.cs @@ -26,6 +26,14 @@ public enum SignalType ClientEncryptedChat } +public enum ChannelType +{ + Text, //Default channel type, handles text, links, files*, all in a linear live chat format + Voice, //Used for general voice and video calls, utilizes WebRTC in its intended use + File, //File browser for connected text channels, used for browsing files rather than scrolling through text channel + Forum, //Specific forum posts, meant to keep conversations grouped and on topic while keeping all in an easy to find place + Stage //Used for announcements and presentations, voice/video call utilizing a modified WebRTC protocol through server +} public sealed class RtcSignalMessage { [JsonPropertyName("type")] @@ -97,6 +105,10 @@ public sealed class ChannelItem { public string ChannelId { get; set; } = string.Empty; public string Name { get; set; } = string.Empty; + + public ChannelType Type { get; set; } + + public string Group { get; set; } = string.Empty; public DateTime CreatedAt { get; set; } }