Class BaseCommandConnection
Base connection class for sending commands to the control server
Implements
Inherited Members
Namespace: DuetAPIClient
Assembly: DuetAPIClient.dll
Syntax
public abstract class BaseCommandConnection : BaseConnection, IDisposable
Constructors
BaseCommandConnection(ConnectionMode)
Protected constructor for derived modes that can issue regular commands
Declaration
protected BaseCommandConnection(ConnectionMode mode)
Parameters
| Type | Name | Description |
|---|---|---|
| ConnectionMode | mode | Connection type |
Methods
AddHttpEndpoint(HttpEndpointType, string, string, bool, int, CancellationToken)
Add a new third-party HTTP endpoint in the format /machine/{ns}/{path}
Declaration
public Task<HttpEndpointUnixSocket> AddHttpEndpoint(HttpEndpointType endpointType, string ns, string path, bool isUploadRequest = false, int backlog = 4, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| HttpEndpointType | endpointType | HTTP request type |
| string | ns | Namespace of the plugin |
| string | path | Endpoint path |
| bool | isUploadRequest | Whether this is an upload request |
| int | backlog | Number of simultaneously pending connections |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<HttpEndpointUnixSocket> | Wrapper around the UNIX socket for accepting HTTP endpoint requests |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Endpoint namespace is reserved |
| InvalidOperationException | Endpoint is already in use |
| IOException | UNIX socket could not be opened |
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
AddUserSession(AccessLevel, SessionType, string?, CancellationToken)
Add a new user session
Declaration
public Task<int> AddUserSession(AccessLevel access, SessionType type, string? origin = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| AccessLevel | access | Access level of this session |
| SessionType | type | Type of this session |
| string | origin | Origin of the user session (e.g. IP address or PID) |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<int> | New session ID |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
CheckPassword(string, CancellationToken)
Check the given password (see M551)
Declaration
public Task<bool> CheckPassword(string password, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | password | Password to check |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<bool> | True if the requested password is correct |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Requested code channel is disabled |
| SocketException | Command could not be processed |
See Also
EvaluateExpression<T>(string, CodeChannel, CancellationToken)
Evaluate an arbitrary expression
Declaration
public Task<T> EvaluateExpression<T>(string expression, CodeChannel channel = CodeChannel.SBC, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | expression | Expression to evaluate |
| CodeChannel | channel | Context of the evaluation |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<T> | Evaluation result |
Type Parameters
| Name | Description |
|---|---|
| T | Type of the evaluation result |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Requested code channel is disabled |
| JsonException | Expected and returned data type do not match |
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
Flush(CodeChannel, CancellationToken)
Wait for all pending codes of the given channel to finish
Declaration
public Task<bool> Flush(CodeChannel channel, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CodeChannel | channel | Code channel to wait for |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<bool> | True if all pending codes could be flushed |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Requested code channel is disabled |
| SocketException | Command could not be processed |
See Also
GetFileInfo(string, bool, CancellationToken)
Parse a G-code file and returns file information about it
Declaration
public Task<GCodeFileInfo> GetFileInfo(string fileName, bool readThumbnailContent, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileName | The file to parse |
| bool | readThumbnailContent | Whether thumbnail content shall be returned |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<GCodeFileInfo> | Information about the parsed file |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
GetFileInfo(string, CancellationToken)
Parse a G-code file and returns file information about it
Declaration
public Task<GCodeFileInfo> GetFileInfo(string fileName, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileName | The file to parse |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<GCodeFileInfo> | Information about the parsed file |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
GetMachineModel(CancellationToken)
Retrieve the full object model of the machine. In subscription mode this is the first command that has to be called once a connection has been established
Declaration
[Obsolete("Deprecated in favor of GetObjectModel")]
public Task<ObjectModel> GetMachineModel(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<ObjectModel> | The current machine model |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
GetObjectModel(CancellationToken)
Retrieve the full object model of the machine. In subscription mode this is the first command that has to be called once a connection has been established
Declaration
public Task<ObjectModel> GetObjectModel(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<ObjectModel> | The current machine model |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
GetSerializedMachineModel(CancellationToken)
Optimized method to directly query the machine model UTF-8 JSON
Declaration
[Obsolete("Deprecated in favor of GetSerializedObjectModel")]
public ValueTask<MemoryStream> GetSerializedMachineModel(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| ValueTask<MemoryStream> | Machine model JSON |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
GetSerializedObjectModel(CancellationToken)
Optimized method to directly query the machine model UTF-8 JSON
Declaration
public Task<string> GetSerializedObjectModel(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<string> | Machine model JSON |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
InstallPlugin(string, CancellationToken)
Install or upgrade a plugin
Declaration
public Task InstallPlugin(string packageFile, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | packageFile | Absolute file path to the plugin ZIP bundle |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
InstallSystemPackage(string, CancellationToken)
Install or upgrade a system package
Declaration
public Task InstallSystemPackage(string packageFile, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | packageFile | Absolute file path to the package file |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
InvalidateChannel(CodeChannel, CancellationToken)
Invalidate all pending codes and files on the given channel
Declaration
public Task InvalidateChannel(CodeChannel channel, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CodeChannel | channel | Code channel where everything is supposed to be invalidated |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Remarks
This does NOT cancel the current code being executed by RRF!
Exceptions
| Type | Condition |
|---|---|
| SocketException | Command could not be processed |
See Also
LockMachineModel(CancellationToken)
Lock the machine model for read/write access. It is MANDATORY to call UnlockMachineModel(CancellationToken) when write access has finished
Declaration
[Obsolete("Deprecated in favor of LockObjectModel")]
public Task LockMachineModel(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
LockObjectModel(CancellationToken)
Lock the machine model for read/write access.
Declaration
public Task<IAsyncDisposable> LockObjectModel(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<IAsyncDisposable> | Asynchronous object model lock |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
PatchMachineModel(string, object, CancellationToken)
Apply a full patch to the object model. Use with care!
Declaration
[Obsolete("Deprecated in favor of PatchObjectModel")]
public Task PatchMachineModel(string key, object patch, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | Key to update |
| object | patch | Patch to apply |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
PatchObjectModel(string, object, CancellationToken)
Apply a full patch to the object model. Use with care!
Declaration
[Obsolete("Deprecated in favor of PatchObjectModel which takes a JsonElement instead of an object")]
public Task PatchObjectModel(string key, object patch, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | Key to update |
| object | patch | Patch to apply |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
PatchObjectModel(string, JsonElement, CancellationToken)
Apply a full patch to the object model. Use with care!
Declaration
public Task PatchObjectModel(string key, JsonElement patch, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | Key to update |
| JsonElement | patch | Patch to apply |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
PerformCode(Code, CancellationToken)
Execute an arbitrary pre-parsed code
Declaration
public Task<Message> PerformCode(Code code, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Code | code | The code to execute |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<Message> | Result of the given code |
Remarks
Cancelling the read operation does not cancel the code execution
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Requested code channel is disabled |
| OperationCanceledException | Code or operation has been cancelled |
| SocketException | Command could not be processed |
See Also
PerformSimpleCode(string, CodeChannel, bool, CancellationToken)
Execute an arbitrary G/M/T-code in text form and return the result as a string
Declaration
public Task<string> PerformSimpleCode(string code, CodeChannel channel, bool executeAsynchronously, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | code | The code to execute |
| CodeChannel | channel | Optional destination channel of this code |
| bool | executeAsynchronously | Execute this code asynchronously in the background |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<string> | Result of the given code converted to a string |
Remarks
Cancelling the read operation does not cancel the code execution
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Requested code channel is disabled |
| OperationCanceledException | Code or operation has been cancelled |
| SocketException | Command could not be processed |
See Also
PerformSimpleCode(string, CodeChannel, CancellationToken)
Execute an arbitrary G/M/T-code in text form and return the result as a string
Declaration
public Task<string> PerformSimpleCode(string code, CodeChannel channel = CodeChannel.SBC, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | code | The code to execute |
| CodeChannel | channel | Optional destination channel of this code |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<string> | Result of the given code converted to a string |
Remarks
Cancelling the read operation does not cancel the code execution
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Requested code channel is disabled |
| OperationCanceledException | Code or operation has been cancelled |
| SocketException | Command could not be processed |
See Also
ReloadPlugin(string, CancellationToken)
Reload a plugin manifest
Declaration
public Task ReloadPlugin(string plugin, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | plugin | Identifier of the plugin |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
RemoveHttpEndpoint(HttpEndpointType, string, string, CancellationToken)
Remove an existing HTTP endpoint
Declaration
public Task<bool> RemoveHttpEndpoint(HttpEndpointType endpointType, string ns, string path, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| HttpEndpointType | endpointType | Type of the endpoint to remove |
| string | ns | Namespace of the endpoint to remove |
| string | path | Endpoint to remove |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<bool> | True if the endpoint could be removed |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
RemoveUserSession(int, CancellationToken)
Remove an existing user session
Declaration
public Task<bool> RemoveUserSession(int id, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | Identifier of the session |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<bool> | True if the session could be removed |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
ResolvePath(string, CancellationToken)
Resolve a RepRapFirmware-style file path to a real file path
Declaration
public Task<string> ResolvePath(string path, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | File path to resolve |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<string> | Resolved file path |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
SetMachineModel(string, string, CancellationToken)
Set a given property to a certain value. Make sure to lock the object model before calling this
Declaration
[Obsolete("Deprecated in favor of SetObjectModel")]
public Task<bool> SetMachineModel(string path, string value, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path to the property |
| string | value | New value as string |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<bool> | True if the property could be updated |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
SetObjectModel(string, string, CancellationToken)
Set a given property to a certain value. Make sure to lock the object model before calling this
Declaration
public Task<bool> SetObjectModel(string path, string value, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path to the property |
| string | value | New value as string |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task<bool> | True if the property could be updated |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
SetPluginData(string, object, string?, CancellationToken)
Set custom plugin data in the object model
Declaration
[Obsolete("Deprecated in favour of new overload which takes a JsonElement argument")]
public Task SetPluginData(string key, object value, string? plugin = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | Key to set |
| object | value | Value to set |
| string | plugin | Identifier of the plugin to update (optional) |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
| UnauthorizedAccessException | Insufficient permissions to modify other plugin data |
See Also
SetPluginData(string, JsonElement, string?, CancellationToken)
Set custom plugin data in the object model
Declaration
public Task SetPluginData(string key, JsonElement value, string? plugin = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | Key to set |
| JsonElement | value | Value to set |
| string | plugin | Identifier of the plugin to update (optional) |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
| UnauthorizedAccessException | Insufficient permissions to modify other plugin data |
See Also
SetUpdateStatus(bool, CancellationToken)
Override the current machine status if a software update is in progress
Declaration
public Task SetUpdateStatus(bool isUpdating, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | isUpdating | If the machine status is supposed to be overrridden |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Remarks
The object model must not be locked when this is called
StartPlugin(string, CancellationToken)
Start a plugin
Declaration
public Task StartPlugin(string plugin, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | plugin | Identifier of the plugin |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
StopPlugin(string, CancellationToken)
Stop a plugin
Declaration
public Task StopPlugin(string plugin, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | plugin | Identifier of the plugin |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
SyncMachineModel(CancellationToken)
Wait for the full machine model to be updated from RepRapFirmware
Declaration
[Obsolete("Deprecated in favor of SyncObjectModel")]
public Task SyncMachineModel(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
SyncObjectModel(CancellationToken)
Wait for the full object model to be updated from RepRapFirmware
Declaration
public Task SyncObjectModel(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
UninstallPlugin(string, CancellationToken)
Uninstall a plugin
Declaration
public Task UninstallPlugin(string plugin, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | plugin | Identifier of the plugin |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
UninstallSystemPackage(string, CancellationToken)
Uninstall a system package
Declaration
public Task UninstallSystemPackage(string package, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | package | Identifier of the package |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
UnlockMachineModel(CancellationToken)
Unlock the machine model again
Declaration
[Obsolete("Deprecated in favor of UnlockObjectModel")]
public Task UnlockMachineModel(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
WriteMessage(Message, bool, LogLevel, CancellationToken)
Write an arbitrary generic message
Declaration
public Task WriteMessage(Message message, bool outputMessage = true, LogLevel logLevel = LogLevel.Off, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Message | message | Message |
| bool | outputMessage | Whether to output the message |
| LogLevel | logLevel | Target log level |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
WriteMessage(Message, bool, bool, CancellationToken)
Write an arbitrary generic message
Declaration
[Obsolete("This overload is deprecated because it lacks support for log levels")]
public Task WriteMessage(Message message, bool outputMessage = true, bool logMessage = false, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Message | message | Message |
| bool | outputMessage | Whether to output the message |
| bool | logMessage | Whether to log the message |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
WriteMessage(MessageType, string, bool, bool, CancellationToken)
Write an arbitrary generic message
Declaration
[Obsolete("This overload is deprecated because it lacks support for log levels")]
public Task WriteMessage(MessageType type, string message, bool outputMessage, bool logMessage, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| MessageType | type | Message type |
| string | message | Message content |
| bool | outputMessage | Whether to output the message |
| bool | logMessage | Whether to log the message |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |
See Also
WriteMessage(MessageType, string, bool, LogLevel?, CancellationToken)
Write an arbitrary generic message
Declaration
public Task WriteMessage(MessageType type, string message, bool outputMessage = true, LogLevel? logLevel = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| MessageType | type | Message type |
| string | message | Message content |
| bool | outputMessage | Whether to output the message |
| LogLevel? | logLevel | Target log level or null to determine log level from the message type |
| CancellationToken | cancellationToken | Optional cancellation token |
Returns
| Type | Description |
|---|---|
| Task | Asynchronous task |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | Operation has been cancelled |
| SocketException | Command could not be processed |