Table of Contents

Class CodeInterception

Namespace
DuetControlServer.IPC.Processors
Assembly
DuetControlServer.dll

Interception processor that notifies clients about G/M/T-codes or comments being processed

public sealed class CodeInterception : IProcessor
Inheritance
CodeInterception
Implements
Inherited Members

Constructors

CodeInterception(Connection, ClientInitMessage, CodeProcessor, IOptions<Settings>)

Constructor of the interception processor

public CodeInterception(Connection conn, ClientInitMessage initMessage, CodeProcessor codeProcessor, IOptions<Settings> settings)

Parameters

conn Connection

Connection instance

initMessage ClientInitMessage

Initialization message

codeProcessor CodeProcessor

Code processor

settings IOptions<Settings>

Settings

Properties

AllSupportedCommands

List of all supported commands

public static Type[] AllSupportedCommands { get; }

Property Value

Type[]

Connection

Connection to the IPC client served by this processor

public Connection Connection { get; }

Property Value

Connection

SupportedCommands

List of specific commands supported in this mode

public static Type[] SupportedCommands { get; }

Property Value

Type[]

Remarks

In addition to these commands, commands of the Command interpreter are supported while a code is being intercepted

Methods

Diagnostics(StringBuilder)

Print diagnostics

public static void Diagnostics(StringBuilder builder)

Parameters

builder StringBuilder

String builder to write to

GetCodeBeingIntercepted(Connection?, out InterceptionMode)

Get the code being intercepted by a given connection

public static Code? GetCodeBeingIntercepted(Connection? connection, out InterceptionMode mode)

Parameters

connection Connection

Connection to look up

mode InterceptionMode

Mode of the corresponding interceptor

Returns

Code

Code being intercepted

InterceptAsync(Code, InterceptionMode, CancellationToken)

Called by the Code class to intercept a code. This method goes through each connected interception channel and notifies the clients.

public static ValueTask<bool> InterceptAsync(Code code, InterceptionMode type, CancellationToken cancellationToken = default)

Parameters

code Code

Code to intercept

type InterceptionMode

Type of the interception

cancellationToken CancellationToken

Cancellation token

Returns

ValueTask<bool>

True if the code has been resolved

Exceptions

OperationCanceledException

Code has been cancelled

IsInterceptingConnection(Connection?)

Checks if the given connection is currently intercepting a code

public static bool IsInterceptingConnection(Connection? connection)

Parameters

connection Connection

Connection ID to check

Returns

bool

True if the connection is intercepting a code

ProcessAsync(CancellationToken)

Waits for commands to be received and enqueues them in a concurrent queue so that a Code can decide when to cancel/resume/resolve the execution.

public Task ProcessAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Cancellation token

Returns

Task

Task that represents the lifecycle of the connection

SetLogger(ILogger<CodeInterception>)

Set the logger (called during initialization)

public static void SetLogger(ILogger<CodeInterception> logger)

Parameters

logger ILogger<CodeInterception>