Implement dynamic channel list

This commit is contained in:
Infi
2024-08-25 01:03:02 +02:00
parent 29e3c6acee
commit 19f10b09c8
8 changed files with 118 additions and 50 deletions
+20 -1
View File
@@ -1,4 +1,5 @@
using ChatTwo.Http.MessageProtocol;
using ChatTwo.Code;
using ChatTwo.Http.MessageProtocol;
using WatsonWebserver.Core;
using WatsonWebserver.Lite;
using ExceptionEventArgs = WatsonWebserver.Core.ExceptionEventArgs;
@@ -72,6 +73,24 @@ public class ServerCore : IAsyncDisposable
Plugin.Log.Error(ex, "Sending channel switch over SSE failed.");
}
}
internal void SendChannelList()
{
try
{
Plugin.Framework.RunOnTick(() =>
{
var channels = Plugin.ChatLogWindow.GetAvailableChannels();
var bundledResponse = new ChannelListEvent(new ChannelList(channels.ToDictionary(pair => pair.Key, pair => (uint)pair.Value)));
foreach (var eventServer in EventConnections)
eventServer.OutboundQueue.Enqueue(bundledResponse);
});
}
catch (Exception ex)
{
Plugin.Log.Error(ex, "Sending channel switch over SSE failed.");
}
}
#endregion
#region GeneralHandlers