using Dalamud.Logging.Internal;
namespace Dalamud.Networking.Pipes.Rpc;
///
/// The Dalamud service repsonsible for hosting the RPC.
///
[ServiceManager.EarlyLoadedService]
internal class RpcHostService : IServiceType, IInternalDisposableService
{
private readonly ModuleLog log = new("RPC");
private readonly PipeRpcHost host;
///
/// Initializes a new instance of the class.
///
[ServiceManager.ServiceConstructor]
public RpcHostService()
{
this.host = new PipeRpcHost();
this.host.Start();
this.log.Information("RpcHostService started on pipe {Pipe}", this.host.PipeName);
}
///
/// Gets the RPC host to drill down.
///
public PipeRpcHost Host => this.host;
///
/// Add a new service Object to the RPC host.
///
/// The object to add.
public void AddService(object service) => this.host.AddService(service);
///
/// Add a new standalone method to the RPC host.
///
/// The method name to add.
/// The handler to add.
public void AddMethod(string name, Delegate handler) => this.host.AddMethod(name, handler);
///
public void DisposeService()
{
this.host.Dispose();
}
}