using Dalamud.Plugin;
using Dalamud.Plugin.Ipc;
namespace Penumbra.Api.Helpers;
///
/// Specialized subscriber only allowing to invoke actions.
///
public class ActionSubscriber
{
private readonly ICallGateSubscriber? _subscriber;
/// Whether the subscriber could successfully be created.
public bool Valid
=> _subscriber != null;
protected ActionSubscriber(IDalamudPluginInterface pi, string label)
{
try
{
_subscriber = pi.GetIpcSubscriber(label);
}
catch (Exception e)
{
PluginLogHelper.WriteError(pi, $"Error registering IPC Subscriber for {label}\n{e}");
_subscriber = null;
}
}
/// Invoke the action. See the source of the subscriber for details.
protected void Invoke()
=> _subscriber?.InvokeAction();
}
///
public class ActionSubscriber
{
private readonly ICallGateSubscriber? _subscriber;
/// Whether the subscriber could successfully be created.
public bool Valid
=> _subscriber != null;
protected ActionSubscriber(IDalamudPluginInterface pi, string label)
{
try
{
_subscriber = pi.GetIpcSubscriber(label);
}
catch (Exception e)
{
PluginLogHelper.WriteError(pi, $"Error registering IPC Subscriber for {label}\n{e}");
_subscriber = null;
}
}
/// Invoke the action. See the source of the subscriber for details.
protected void Invoke(T1 a)
=> _subscriber?.InvokeAction(a);
}
///
public class ActionSubscriber
{
private readonly ICallGateSubscriber? _subscriber;
///
public bool Valid
=> _subscriber != null;
protected ActionSubscriber(IDalamudPluginInterface pi, string label)
{
try
{
_subscriber = pi.GetIpcSubscriber(label);
}
catch (Exception e)
{
PluginLogHelper.WriteError(pi, $"Error registering IPC Subscriber for {label}\n{e}");
_subscriber = null;
}
}
///
protected void Invoke(T1 a, T2 b)
=> _subscriber?.InvokeAction(a, b);
}
///
public class ActionSubscriber
{
private readonly ICallGateSubscriber? _subscriber;
///
public bool Valid
=> _subscriber != null;
protected ActionSubscriber(IDalamudPluginInterface pi, string label)
{
try
{
_subscriber = pi.GetIpcSubscriber(label);
}
catch (Exception e)
{
PluginLogHelper.WriteError(pi, $"Error registering IPC Subscriber for {label}\n{e}");
_subscriber = null;
}
}
///
protected void Invoke(T1 a, T2 b, T3 c)
=> _subscriber?.InvokeAction(a, b, c);
}