Setting stage for channel types and groups

This commit is contained in:
2026-04-22 21:35:21 -04:00
parent 3b75c2b785
commit 0c9ff3b5d9
5 changed files with 36 additions and 6 deletions

View File

@@ -335,9 +335,11 @@ public partial class MainPage : ContentPage
foreach (var channel in _channels.OrderBy(c => c.CreatedAt)) 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 += (_, _) => button.Clicked += (_, _) =>
@@ -348,6 +350,11 @@ public partial class MainPage : ContentPage
MainThread.BeginInvokeOnMainThread(async () => MainThread.BeginInvokeOnMainThread(async () =>
{ {
await PushRtcContextToJsAsync(); await PushRtcContextToJsAsync();
if (channel.Type == ChannelType.Voice)
{
SwapView();
// JoinRtcChannel(); //TODO: Join voice calls when clicking channel rather than a separate button
}
}); });
ChannelLabel.Text = $"#{_currentChannelName}"; ChannelLabel.Text = $"#{_currentChannelName}";
@@ -409,7 +416,7 @@ public partial class MainPage : ContentPage
await MessagesScrollView.ScrollToAsync(MessagesLayout, ScrollToPosition.End, true); await MessagesScrollView.ScrollToAsync(MessagesLayout, ScrollToPosition.End, true);
} }
private void SwapView_OnClicked(object? sender, EventArgs e) private void SwapView()
{ {
if (RtcView.IsVisible) if (RtcView.IsVisible)
{ {
@@ -425,6 +432,10 @@ public partial class MainPage : ContentPage
ViewSwapped.Text = "Swap to Message View"; ViewSwapped.Text = "Swap to Message View";
} }
} }
private void SwapView_OnClicked(object? sender, EventArgs e)
{
SwapView();
}
#region RTC Functions #region RTC Functions
public async Task<bool> JoinRtcChannel() public async Task<bool> JoinRtcChannel()
@@ -649,6 +660,12 @@ public partial class MainPage : ContentPage
}); });
} }
public class ChannelButton : Button
{
public ChannelType Type { get; set; }
public string Group { get; set; }
}
[JsonSourceGenerationOptions(WriteIndented = false)] [JsonSourceGenerationOptions(WriteIndented = false)]
[JsonSerializable(typeof(RtcDescription))] [JsonSerializable(typeof(RtcDescription))]
[JsonSerializable(typeof(List<RtcSignalMessage>))] [JsonSerializable(typeof(List<RtcSignalMessage>))]

View File

@@ -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() { async function joinChannelCall() {
LogMessage("Current username: " + currentUsername); LogMessage("Current username: " + currentUsername);
LogMessage("Current channel: " + currentChannelId); LogMessage("Current channel: " + currentChannelId);

View File

@@ -34,8 +34,6 @@ var wssv = new WebSocketServer("ws://localhost:1337");
wssv.AddWebSocketService<ChatSocketBehavior>("/"); wssv.AddWebSocketService<ChatSocketBehavior>("/");
RtcNotificationService.Server = wssv; 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(); wssv.Start();
Console.WriteLine("WebSocket server started"); Console.WriteLine("WebSocket server started");

View File

@@ -206,7 +206,7 @@ public class ChatSocketBehavior : WebSocketBehavior
Console.WriteLine("Db is not initialized."); Console.WriteLine("Db is not initialized.");
return; return;
} }
//TODO: Update to include ChannelType and Group String on channels
var channels = GetChannelsSync() var channels = GetChannelsSync()
.OrderBy(c => c.CreatedAt) .OrderBy(c => c.CreatedAt)
.Select(c => new ChannelItem() .Select(c => new ChannelItem()

View File

@@ -26,6 +26,14 @@ public enum SignalType
ClientEncryptedChat 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 public sealed class RtcSignalMessage
{ {
[JsonPropertyName("type")] [JsonPropertyName("type")]
@@ -97,6 +105,10 @@ public sealed class ChannelItem
{ {
public string ChannelId { get; set; } = string.Empty; public string ChannelId { get; set; } = string.Empty;
public string Name { 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; } public DateTime CreatedAt { get; set; }
} }