Class SubscribeConnection
Connection class for subscribing to model updates
Implements
Inherited Members
Namespace: DuetAPIClient
Assembly: DuetAPIClient.dll
Syntax
public sealed class SubscribeConnection : BaseConnection, IDisposable
Constructors
SubscribeConnection()
Creates a new connection in subscriber mode
Declaration
public SubscribeConnection()
Properties
Channel
Code channel to receive messages from. If not set, only generic messages are forwarded (as in v3.3 and earlier)
Declaration
public CodeChannel? Channel { get; }
Property Value
Type | Description |
---|---|
CodeChannel? |
Remarks
This has no effect in Full mode
Filter
Delimited filter expression
Declaration
[Obsolete("Use Filters instead")]
public string? Filter { get; }
Property Value
Type | Description |
---|---|
string |
See Also
Filters
Filter expressions
Declaration
public List<string> Filters { get; }
Property Value
Type | Description |
---|---|
List<string> |
See Also
Mode
Mode of the subscription
Declaration
public SubscriptionMode Mode { get; }
Property Value
Type | Description |
---|---|
SubscriptionMode |
Methods
Connect(SubscriptionMode, IEnumerable<string>?, string, CancellationToken)
Establishes a connection to the given UNIX socket file
Declaration
public Task Connect(SubscriptionMode mode, IEnumerable<string>? filters = null, string socketPath = "/run/dsf/dcs.sock", CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
SubscriptionMode | mode | Subscription mode |
IEnumerable<string> | filters | Optional filter strings |
string | socketPath | Path to the UNIX socket file |
CancellationToken | cancellationToken | Optional cancellation token |
Returns
Type | Description |
---|---|
Task | Asynchronous task |
Exceptions
Type | Condition |
---|---|
IncompatibleVersionException | API level is incompatible |
IOException | Connection mode is unavailable |
OperationCanceledException | Operation has been cancelled |
SocketException | Init message could not be processed |
Connect(SubscriptionMode, CodeChannel?, IEnumerable<string>?, string, CancellationToken)
Establishes a connection to the given UNIX socket file
Declaration
public Task Connect(SubscriptionMode mode, CodeChannel? channel, IEnumerable<string>? filters = null, string socketPath = "/run/dsf/dcs.sock", CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
SubscriptionMode | mode | Subscription mode |
CodeChannel? | channel | Optional code channel to receive messages from (not applicable in Full mode) |
IEnumerable<string> | filters | Optional filter strings |
string | socketPath | Path to the UNIX socket file |
CancellationToken | cancellationToken | Optional cancellation token |
Returns
Type | Description |
---|---|
Task | Asynchronous task |
Exceptions
Type | Condition |
---|---|
IncompatibleVersionException | API level is incompatible |
IOException | Connection mode is unavailable |
OperationCanceledException | Operation has been cancelled |
SocketException | Init message could not be processed |
Connect(SubscriptionMode, string, string, CancellationToken)
Establishes a connection to the given UNIX socket file
Declaration
[Obsolete("Use the new Connect overload with a filter list instead")]
public Task Connect(SubscriptionMode mode, string filter, string socketPath = "/run/dsf/dcs.sock", CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
SubscriptionMode | mode | Subscription mode |
string | filter | Optional delimited filter string |
string | socketPath | Path to the UNIX socket file |
CancellationToken | cancellationToken | Optional cancellation token |
Returns
Type | Description |
---|---|
Task | Asynchronous task |
Exceptions
Type | Condition |
---|---|
IncompatibleVersionException | API level is incompatible |
IOException | Connection mode is unavailable |
OperationCanceledException | Operation has been cancelled |
SocketException | Init message could not be processed |
GetMachineModel(CancellationToken)
Retrieves the full machine 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("Use GetObjectModel instead")]
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 | Receipt could not be acknowledged |
See Also
GetMachineModelPatch(CancellationToken)
Receive a (partial) machine model update. If the subscription mode is set to Patch, new update patches of the object model need to be applied manually. This method is intended to receive such fragments.
Declaration
[Obsolete("Use GetObjectModelPatch instead")]
public Task<JsonDocument> GetMachineModelPatch(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | An optional cancellation token |
Returns
Type | Description |
---|---|
Task<JsonDocument> | The partial update JSON |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | Operation has been cancelled |
SocketException | Receipt could not be acknowledged |
See Also
GetObjectModel(CancellationToken)
Retrieves 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 | Receipt could not be acknowledged |
See Also
GetObjectModelPatch(CancellationToken)
Receive a (partial) object model update. If the subscription mode is set to Patch, new update patches of the object model need to be applied manually. This method is intended to receive such fragments.
Declaration
public Task<JsonDocument> GetObjectModelPatch(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | An optional cancellation token |
Returns
Type | Description |
---|---|
Task<JsonDocument> | The partial update JSON |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | Operation has been cancelled |
SocketException | Receipt could not be acknowledged |
See Also
GetSerializedMachineModel(CancellationToken)
Optimized method to query the machine model UTF-8 JSON in any mode. May be used to get machine model patches as well.
Declaration
[Obsolete("Use GetSerializedObjectModel instead")]
public Task<MemoryStream> GetSerializedMachineModel(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | Optional cancellation token |
Returns
Type | Description |
---|---|
Task<MemoryStream> | Machine model JSON |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | Operation has been cancelled |
SocketException | Receipt could not be acknowledged |
See Also
GetSerializedObjectModel(CancellationToken)
Optimized method to query the object model UTF-8 JSON in any mode. May be used to get machine model patches as well.
Declaration
public Task<MemoryStream> GetSerializedObjectModel(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | Optional cancellation token |
Returns
Type | Description |
---|---|
Task<MemoryStream> | Machine model JSON |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | Operation has been cancelled |
SocketException | Receipt could not be acknowledged |