- Partially implement tab switch

- Better support character switch
This commit is contained in:
Infi
2024-08-28 18:18:20 +02:00
parent 17ed40307c
commit f6531907a4
7 changed files with 35 additions and 5 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.28.2</Version>
<Version>1.29.0</Version>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
+3
View File
@@ -164,6 +164,9 @@ internal sealed unsafe class Chat : IDisposable
return;
ChangeChannelNameDetour(agent);
// Inform all clients that a new login happend
Plugin.ServerCore.SendNewLogin();
}
private byte ChatLogRefreshDetour(nint log, ushort eventId, AtkValue* value)
+3 -1
View File
@@ -38,10 +38,12 @@ public class HostContext
Host.Events.ExceptionEncountered += ExceptionEncountered;
// Settings
#if DEBUG
Host.Settings.Debug.Requests = true;
Host.Settings.Debug.Routing = true;
Host.Settings.Debug.Responses = true;
Host.Settings.Debug.AccessControl = true;
#endif
Host.Events.Logger = logMessage => Plugin.Log.Information(logMessage);
IsActive = true;
@@ -116,7 +118,6 @@ public class HostContext
{
await ctx.Response.Send("Nothing to see here.");
}
#endregion
private async Task CheckAuthenticationCookie(HttpContextBase ctx)
{
@@ -132,4 +133,5 @@ public class HostContext
// Do nothing to let auth pass
}
#endregion
}
+2 -1
View File
@@ -50,7 +50,8 @@ public class Processing
var channels = await Plugin.Framework.RunOnTick(Plugin.ChatLogWindow.GetAvailableChannels);
var channelName = await Plugin.Framework.RunOnTick(() => ReadChannelName(Plugin.ChatLogWindow.PreviousChannel));
sse.OutboundQueue.Enqueue(new NewMessageEvent(new Messages(messages)));
// Using the bulk message event to clear everything on the client side that may still exist
sse.OutboundQueue.Enqueue(new BulkMessagesEvent(new Messages(messages)));
sse.OutboundQueue.Enqueue(new SwitchChannelEvent(new SwitchChannel(channelName)));
sse.OutboundQueue.Enqueue(new ChannelListEvent(new ChannelList(channels.ToDictionary(pair => pair.Key, pair => (uint)pair.Value))));
}
+19
View File
@@ -92,6 +92,25 @@ public class ServerCore : IAsyncDisposable
Plugin.Log.Error(ex, "Sending channel switch over SSE failed.");
}
}
internal void SendNewLogin()
{
if (!HostContext.IsActive)
return;
try
{
Plugin.Framework.RunOnTick(async () =>
{
foreach (var eventServer in HostContext.EventConnections)
await HostContext.Processing.PrepareNewClient(eventServer);
});
}
catch (Exception ex)
{
Plugin.Log.Error(ex, "Preparing all clients after login failed.");
}
}
#endregion
public void InvalidateSessions()
+3 -2
View File
@@ -88,6 +88,9 @@ public sealed class Plugin : IDalamudPlugin
ExtraChat = new ExtraChat(this);
FontManager = new FontManager();
// ChatLog calls this in its ctor if the player is already logged in
ServerCore = new ServerCore(this);
ChatLogWindow = new ChatLogWindow(this);
SettingsWindow = new SettingsWindow(this);
DbViewer = new DbViewer(this);
@@ -130,8 +133,6 @@ public sealed class Plugin : IDalamudPlugin
AutoTranslate.PreloadCache();
#endif
ServerCore = new ServerCore(this);
// Automatically start the webserver if requested
if (Config.WebinterfaceAutoStart)
{
+4
View File
@@ -374,6 +374,10 @@ public sealed class ChatLogWindow : Window
// If channel is null it doesn't have a default, and we never selected this channel before
if (channel != null)
SetChannel(tab.Channel ?? tab.PreviousChannel);
// Inform the webinterface about tab switch
// TODO implement tabs in the webinterface
Plugin.ServerCore.SendNewLogin();
}
internal static bool InBattle => Plugin.Condition[ConditionFlag.InCombat];