mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 13:14:17 +01:00
Use external library for API interface and IPC.
This commit is contained in:
parent
b3f048bfe6
commit
918d5db6a6
69 changed files with 4026 additions and 1873 deletions
54
tmp/Helpers/ActionSubscriber.cs
Normal file
54
tmp/Helpers/ActionSubscriber.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using Dalamud.Logging;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Ipc;
|
||||
|
||||
namespace Penumbra.Api.Helpers;
|
||||
|
||||
public readonly struct ActionSubscriber< T1 >
|
||||
{
|
||||
private readonly ICallGateSubscriber< T1, object? >? _subscriber;
|
||||
|
||||
public bool Valid
|
||||
=> _subscriber != null;
|
||||
|
||||
public ActionSubscriber( DalamudPluginInterface pi, string label )
|
||||
{
|
||||
try
|
||||
{
|
||||
_subscriber = pi.GetIpcSubscriber< T1, object? >( label );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
PluginLog.Error( $"Error registering IPC Subscriber for {label}\n{e}" );
|
||||
_subscriber = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Invoke( T1 a )
|
||||
=> _subscriber?.InvokeAction( a );
|
||||
}
|
||||
|
||||
public readonly struct ActionSubscriber< T1, T2 >
|
||||
{
|
||||
private readonly ICallGateSubscriber< T1, T2, object? >? _subscriber;
|
||||
|
||||
public bool Valid
|
||||
=> _subscriber != null;
|
||||
|
||||
public ActionSubscriber( DalamudPluginInterface pi, string label )
|
||||
{
|
||||
try
|
||||
{
|
||||
_subscriber = pi.GetIpcSubscriber< T1, T2, object? >( label );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
PluginLog.Error( $"Error registering IPC Subscriber for {label}\n{e}" );
|
||||
_subscriber = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Invoke( T1 a, T2 b )
|
||||
=> _subscriber?.InvokeAction( a, b );
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue