Table of Contents

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

conn Connection

Connection instance

initMessage ClientInitMessage

Initialization message from the client

commandFactory CommandFactory

Command factory to create commands

model ObjectModel

Object model instance

logger ILogger<PluginService>

Logger instance

settings IOptions<Settings>

Settings

Properties

Connection

Connection to the IPC client served by this processor

public Connection Connection { get; }

Property Value

Connection

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

int

Methods

IsConnected(bool)

Check if the requested plugin service is currently connected

public static bool IsConnected(bool asRoot)

Parameters

asRoot bool

Whether 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

command BaseCommand

Command to perform

asRoot bool

Send it to the service running as root

cancellationToken CancellationToken

Optional 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

command BaseCommand

Command to perform

asRoot bool

Send it to the service running as root

cancellationToken CancellationToken

Optional cancellation token

Returns

Task<T>

Deserialized command result

Type Parameters

T

Expected result type (must be registered in CommandContext)

ProcessAsync(CancellationToken)

Handles the remote connection

public Task ProcessAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Cancellation token to cancel the worker

Returns

Task

Asynchronous task