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
connConnectionConnection instance
initMessageClientInitMessageInitialization message
codeProcessorCodeProcessorCode processor
settingsIOptions<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
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
builderStringBuilderString 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
connectionConnectionConnection to look up
modeInterceptionModeMode 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
codeCodeCode to intercept
typeInterceptionModeType of the interception
cancellationTokenCancellationTokenCancellation token
Returns
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
connectionConnectionConnection 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
cancellationTokenCancellationTokenCancellation 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
loggerILogger<CodeInterception>