Class PluginService
- Namespace
- DuetControlServer.IPC.Processors
- Assembly
- DuetControlServer.dll
IPC processor for plugin services
public sealed class PluginService : IProcessor
- Inheritance
-
PluginService
- Implements
- Inherited Members
Constructors
PluginService(Connection, ClientInitMessage, CommandFactory, ObjectModel, ILogger<PluginService>, IOptions<Settings>)
Constructor of the plugin runner proxy processor
public PluginService(Connection conn, ClientInitMessage initMessage, CommandFactory commandFactory, ObjectModel model, ILogger<PluginService> logger, IOptions<Settings> settings)
Parameters
connConnectionConnection instance
initMessageClientInitMessageInitialization message from the client
commandFactoryCommandFactoryCommand factory to create commands
modelObjectModelObject model instance
loggerILogger<PluginService>Logger instance
settingsIOptions<Settings>Settings
Properties
Connection
Connection to the IPC client served by this processor
public Connection Connection { get; }
Property Value
ServicePid
Peer PID of the currently-connected non-root plugin service, or 0 if none is connected. Used by DCS to authenticate DPS's internal command connections so that a plugin re-execing DuetPluginService (with LD_PRELOAD or otherwise) cannot masquerade as the real DPS - its PID won't match
public static int ServicePid { get; }
Property Value
Methods
IsConnected(bool)
Check if the requested plugin service is currently connected
public static bool IsConnected(bool asRoot)
Parameters
asRootboolWhether to check the root plugin service
Returns
- bool
True if the service is connected
PerformCommandAsync(BaseCommand, bool, CancellationToken)
Perform a command via the plugin service
public static Task PerformCommandAsync(BaseCommand command, bool asRoot, CancellationToken cancellationToken = default)
Parameters
commandBaseCommandCommand to perform
asRootboolSend it to the service running as root
cancellationTokenCancellationTokenOptional cancellation token
Returns
- Task
Asynchronous task
PerformCommandAsync<T>(BaseCommand, bool, CancellationToken)
Perform a command via the plugin service and return its typed result
public static Task<T?> PerformCommandAsync<T>(BaseCommand command, bool asRoot, CancellationToken cancellationToken = default)
Parameters
commandBaseCommandCommand to perform
asRootboolSend it to the service running as root
cancellationTokenCancellationTokenOptional cancellation token
Returns
- Task<T>
Deserialized command result
Type Parameters
TExpected result type (must be registered in CommandContext)
ProcessAsync(CancellationToken)
Handles the remote connection
public Task ProcessAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token to cancel the worker
Returns
- Task
Asynchronous task