forked from aly/qstbak
qstcompanion v1.0.6
This commit is contained in:
parent
5e1e1decc5
commit
ada27cf05b
30 changed files with 3403 additions and 426 deletions
|
|
@ -21,6 +21,8 @@ public class MultiClientIPC : IDisposable
|
|||
|
||||
private readonly ICallGateProvider<string, ushort, object?> passengerMountedProvider;
|
||||
|
||||
private readonly ICallGateProvider<string, ushort, string, object?> helperStatusProvider;
|
||||
|
||||
private readonly ICallGateSubscriber<string, ushort, object?> requestHelperSubscriber;
|
||||
|
||||
private readonly ICallGateSubscriber<object?> dismissHelperSubscriber;
|
||||
|
|
@ -31,6 +33,8 @@ public class MultiClientIPC : IDisposable
|
|||
|
||||
private readonly ICallGateSubscriber<string, ushort, object?> passengerMountedSubscriber;
|
||||
|
||||
private readonly ICallGateSubscriber<string, ushort, string, object?> helperStatusSubscriber;
|
||||
|
||||
public event Action<string, ushort>? OnHelperRequested;
|
||||
|
||||
public event Action? OnHelperDismissed;
|
||||
|
|
@ -41,6 +45,8 @@ public class MultiClientIPC : IDisposable
|
|||
|
||||
public event Action<string, ushort>? OnPassengerMounted;
|
||||
|
||||
public event Action<string, ushort, string>? OnHelperStatusUpdate;
|
||||
|
||||
public MultiClientIPC(IDalamudPluginInterface pluginInterface, IPluginLog log)
|
||||
{
|
||||
this.pluginInterface = pluginInterface;
|
||||
|
|
@ -50,11 +56,13 @@ public class MultiClientIPC : IDisposable
|
|||
helperAvailableProvider = pluginInterface.GetIpcProvider<string, ushort, object>("QSTCompanion.HelperAvailable");
|
||||
chatMessageProvider = pluginInterface.GetIpcProvider<string, object>("QSTCompanion.ChatMessage");
|
||||
passengerMountedProvider = pluginInterface.GetIpcProvider<string, ushort, object>("QSTCompanion.PassengerMounted");
|
||||
helperStatusProvider = pluginInterface.GetIpcProvider<string, ushort, string, object>("QSTCompanion.HelperStatus");
|
||||
requestHelperSubscriber = pluginInterface.GetIpcSubscriber<string, ushort, object>("QSTCompanion.RequestHelper");
|
||||
dismissHelperSubscriber = pluginInterface.GetIpcSubscriber<object>("QSTCompanion.DismissHelper");
|
||||
helperAvailableSubscriber = pluginInterface.GetIpcSubscriber<string, ushort, object>("QSTCompanion.HelperAvailable");
|
||||
chatMessageSubscriber = pluginInterface.GetIpcSubscriber<string, object>("QSTCompanion.ChatMessage");
|
||||
passengerMountedSubscriber = pluginInterface.GetIpcSubscriber<string, ushort, object>("QSTCompanion.PassengerMounted");
|
||||
helperStatusSubscriber = pluginInterface.GetIpcSubscriber<string, ushort, string, object>("QSTCompanion.HelperStatus");
|
||||
requestHelperProvider.RegisterFunc(delegate(string name, ushort worldId)
|
||||
{
|
||||
OnRequestHelperReceived(name, worldId);
|
||||
|
|
@ -80,6 +88,11 @@ public class MultiClientIPC : IDisposable
|
|||
OnPassengerMountedReceived(questerName, questerWorld);
|
||||
return (object?)null;
|
||||
});
|
||||
helperStatusProvider.RegisterFunc(delegate(string helperName, ushort helperWorld, string status)
|
||||
{
|
||||
OnHelperStatusReceived(helperName, helperWorld, status);
|
||||
return (object?)null;
|
||||
});
|
||||
log.Information("[MultiClientIPC] ✅ IPC initialized successfully");
|
||||
}
|
||||
|
||||
|
|
@ -213,6 +226,32 @@ public class MultiClientIPC : IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
public void BroadcastHelperStatus(string helperName, ushort worldId, string status)
|
||||
{
|
||||
try
|
||||
{
|
||||
log.Debug($"[MultiClientIPC] Broadcasting helper status: {helperName}@{worldId} = {status}");
|
||||
helperStatusSubscriber.InvokeFunc(helperName, worldId, status);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Error("[MultiClientIPC] Failed to broadcast helper status: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnHelperStatusReceived(string helperName, ushort helperWorld, string status)
|
||||
{
|
||||
try
|
||||
{
|
||||
log.Debug($"[MultiClientIPC] Received helper status: {helperName}@{helperWorld} = {status}");
|
||||
this.OnHelperStatusUpdate?.Invoke(helperName, helperWorld, status);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Error("[MultiClientIPC] Error handling helper status: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
|
|
@ -221,6 +260,7 @@ public class MultiClientIPC : IDisposable
|
|||
dismissHelperProvider.UnregisterFunc();
|
||||
helperAvailableProvider.UnregisterFunc();
|
||||
chatMessageProvider.UnregisterFunc();
|
||||
helperStatusProvider.UnregisterFunc();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue