mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
CR changes
This commit is contained in:
parent
78ed4a2b01
commit
4937a2f4bd
4 changed files with 15 additions and 32 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
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
|
||||
}
|
||||
var du = DalamudUri.FromUri(uri);
|
||||
this.Dispatch(du);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue