Files
LightlessClient/LightlessSync/Interop/Ipc/IpcManager.cs
2025-12-30 23:43:22 -06:00

65 lines
2.2 KiB
C#

using LightlessSync.Services.Mediator;
using Microsoft.Extensions.Logging;
namespace LightlessSync.Interop.Ipc;
public sealed partial class IpcManager : DisposableMediatorSubscriberBase
{
public IpcManager(ILogger<IpcManager> logger, LightlessMediator mediator,
IpcCallerPenumbra penumbraIpc, IpcCallerGlamourer glamourerIpc, IpcCallerCustomize customizeIpc, IpcCallerHeels heelsIpc,
IpcCallerHonorific honorificIpc, IpcCallerMoodles moodlesIpc, IpcCallerPetNames ipcCallerPetNames, IpcCallerBrio ipcCallerBrio,
IpcCallerLifestream ipcCallerLifestream) : base(logger, mediator)
{
CustomizePlus = customizeIpc;
Heels = heelsIpc;
Glamourer = glamourerIpc;
Penumbra = penumbraIpc;
Honorific = honorificIpc;
Moodles = moodlesIpc;
PetNames = ipcCallerPetNames;
Brio = ipcCallerBrio;
Lifestream = ipcCallerLifestream;
if (Initialized)
{
Mediator.Publish(new PenumbraInitializedMessage());
}
Mediator.Subscribe<DelayedFrameworkUpdateMessage>(this, (_) => PeriodicApiStateCheck());
try
{
PeriodicApiStateCheck();
}
catch (Exception ex)
{
logger.LogWarning(ex, "Failed to check for some IPC, plugin not installed?");
}
}
public bool Initialized => Penumbra.APIAvailable && Glamourer.APIAvailable;
public IpcCallerCustomize CustomizePlus { get; init; }
public IpcCallerHonorific Honorific { get; init; }
public IpcCallerHeels Heels { get; init; }
public IpcCallerGlamourer Glamourer { get; }
public IpcCallerPenumbra Penumbra { get; }
public IpcCallerMoodles Moodles { get; }
public IpcCallerPetNames PetNames { get; }
public IpcCallerBrio Brio { get; }
public IpcCallerLifestream Lifestream { get; }
private void PeriodicApiStateCheck()
{
Penumbra.CheckAPI();
Penumbra.CheckModDirectory();
Glamourer.CheckAPI();
Heels.CheckAPI();
CustomizePlus.CheckAPI();
Honorific.CheckAPI();
Moodles.CheckAPI();
PetNames.CheckAPI();
Brio.CheckAPI();
Lifestream.CheckAPI();
}
}