CR changes

This commit is contained in:
Kaz Wolfe 2025-11-16 18:14:02 -08:00
parent 78ed4a2b01
commit 4937a2f4bd
No known key found for this signature in database
GPG key ID: 258813F53A16EBB4
4 changed files with 15 additions and 32 deletions

View file

@ -1,5 +1,6 @@
using System.Linq;
using Dalamud.Console;
using Dalamud.IoC;
using Dalamud.IoC.Internal;
using Dalamud.Networking.Pipes.Internal;
@ -43,7 +44,8 @@ public class PluginLinkHandler : IInternalDisposableService, IPluginLinkHandler
private void HandleUri(DalamudUri uri)
{
var target = uri.Path.Split("/").FirstOrDefault();
if (target == null || !string.Equals(target, this.localPlugin.InternalName, StringComparison.OrdinalIgnoreCase))
var thisPlugin = ConsoleManagerPluginUtil.GetSanitizedNamespaceName(this.localPlugin.InternalName);
if (target == null || !string.Equals(target, thisPlugin, StringComparison.OrdinalIgnoreCase))
{
return;
}

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using Dalamud.Logging.Internal;
using Dalamud.Networking.Pipes.Rpc;
using Dalamud.Utility;
namespace Dalamud.Networking.Pipes.Internal;
@ -65,10 +66,7 @@ internal class LinkHandlerService : IInternalDisposableService
if (!this.handlers.TryGetValue(ns, out var list))
return;
lock (list)
{
list.RemoveAll(x => x == handler);
}
if (list.Count == 0)
this.handlers.TryRemove(ns, out _);
@ -85,25 +83,12 @@ internal class LinkHandlerService : IInternalDisposableService
this.log.Information("Received URI: {Uri}", uri.ToString());
var ns = uri.Namespace;
if (!this.handlers.TryGetValue(ns, out var list))
if (!this.handlers.TryGetValue(ns, out var actions))
return;
Action<DalamudUri>[] snapshot;
lock (list)
foreach (var h in actions)
{
snapshot = list.ToArray();
}
foreach (var h in snapshot)
{
try
{
h(uri);
}
catch (Exception e)
{
this.log.Warning(e, "Link handler threw for {UriPath}", uri.Path);
}
h.InvokeSafely(uri);
}
}
@ -116,14 +101,7 @@ internal class LinkHandlerService : IInternalDisposableService
if (string.IsNullOrWhiteSpace(uri))
return;
try
{
var du = DalamudUri.FromUri(uri);
this.Dispatch(du);
}
catch (Exception)
{
// swallow parse errors; clients shouldn't crash the host
}
}
}

View file

@ -53,7 +53,7 @@ internal class PipeRpcHost : IDisposable
public void Start()
{
if (this.acceptLoopTask != null) return;
this.acceptLoopTask = Task.Run(this.AcceptLoopAsync);
this.acceptLoopTask = Task.Factory.StartNew(this.AcceptLoopAsync, TaskCreationOptions.LongRunning);
}
/// <summary>Invoke an RPC request on a specific client expecting a result.</summary>

View file

@ -1,4 +1,6 @@
using Dalamud.Networking.Pipes;
using System.Diagnostics.CodeAnalysis;
using Dalamud.Networking.Pipes;
namespace Dalamud.Plugin.Services;
@ -6,6 +8,7 @@ namespace Dalamud.Plugin.Services;
/// A service to allow plugins to subscribe to dalamud:// URIs targeting them. Plugins will receive any URI sent to the
/// <code>dalamud://plugin/{PLUGIN_INTERNAL_NAME}/...</code> namespace.
/// </summary>
[Experimental("DAL_RPC", Message = "This service will be finalized around 7.41 and may change before then.")]
public interface IPluginLinkHandler
{
/// <summary>