mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +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 System.Linq;
|
||||||
|
|
||||||
|
using Dalamud.Console;
|
||||||
using Dalamud.IoC;
|
using Dalamud.IoC;
|
||||||
using Dalamud.IoC.Internal;
|
using Dalamud.IoC.Internal;
|
||||||
using Dalamud.Networking.Pipes.Internal;
|
using Dalamud.Networking.Pipes.Internal;
|
||||||
|
|
@ -43,7 +44,8 @@ public class PluginLinkHandler : IInternalDisposableService, IPluginLinkHandler
|
||||||
private void HandleUri(DalamudUri uri)
|
private void HandleUri(DalamudUri uri)
|
||||||
{
|
{
|
||||||
var target = uri.Path.Split("/").FirstOrDefault();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
using Dalamud.Logging.Internal;
|
using Dalamud.Logging.Internal;
|
||||||
using Dalamud.Networking.Pipes.Rpc;
|
using Dalamud.Networking.Pipes.Rpc;
|
||||||
|
using Dalamud.Utility;
|
||||||
|
|
||||||
namespace Dalamud.Networking.Pipes.Internal;
|
namespace Dalamud.Networking.Pipes.Internal;
|
||||||
|
|
||||||
|
|
@ -65,10 +66,7 @@ internal class LinkHandlerService : IInternalDisposableService
|
||||||
if (!this.handlers.TryGetValue(ns, out var list))
|
if (!this.handlers.TryGetValue(ns, out var list))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lock (list)
|
|
||||||
{
|
|
||||||
list.RemoveAll(x => x == handler);
|
list.RemoveAll(x => x == handler);
|
||||||
}
|
|
||||||
|
|
||||||
if (list.Count == 0)
|
if (list.Count == 0)
|
||||||
this.handlers.TryRemove(ns, out _);
|
this.handlers.TryRemove(ns, out _);
|
||||||
|
|
@ -85,25 +83,12 @@ internal class LinkHandlerService : IInternalDisposableService
|
||||||
this.log.Information("Received URI: {Uri}", uri.ToString());
|
this.log.Information("Received URI: {Uri}", uri.ToString());
|
||||||
|
|
||||||
var ns = uri.Namespace;
|
var ns = uri.Namespace;
|
||||||
if (!this.handlers.TryGetValue(ns, out var list))
|
if (!this.handlers.TryGetValue(ns, out var actions))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Action<DalamudUri>[] snapshot;
|
foreach (var h in actions)
|
||||||
lock (list)
|
|
||||||
{
|
{
|
||||||
snapshot = list.ToArray();
|
h.InvokeSafely(uri);
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var h in snapshot)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
h(uri);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
this.log.Warning(e, "Link handler threw for {UriPath}", uri.Path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,14 +101,7 @@ internal class LinkHandlerService : IInternalDisposableService
|
||||||
if (string.IsNullOrWhiteSpace(uri))
|
if (string.IsNullOrWhiteSpace(uri))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var du = DalamudUri.FromUri(uri);
|
var du = DalamudUri.FromUri(uri);
|
||||||
this.Dispatch(du);
|
this.Dispatch(du);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
// swallow parse errors; clients shouldn't crash the host
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ internal class PipeRpcHost : IDisposable
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
if (this.acceptLoopTask != null) return;
|
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>
|
/// <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;
|
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
|
/// 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.
|
/// <code>dalamud://plugin/{PLUGIN_INTERNAL_NAME}/...</code> namespace.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Experimental("DAL_RPC", Message = "This service will be finalized around 7.41 and may change before then.")]
|
||||||
public interface IPluginLinkHandler
|
public interface IPluginLinkHandler
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue