Method GetOrCreateMqttClientAgentAsync
- Namespace
- Kepware.Api.ClientHandler
- Assembly
- Kepware.Api.dll
GetOrCreateMqttClientAgentAsync(string, IDictionary<string, object>?, CancellationToken)
Gets or creates an MQTT Client agent with the specified name. If the agent exists, it is loaded and returned. If it does not exist, it is created with the specified properties.
public Task<MqttClientAgent> GetOrCreateMqttClientAgentAsync(string name, IDictionary<string, object>? properties = null, CancellationToken cancellationToken = default)
Parameters
namestringThe name of the agent.
propertiesIDictionary<string, object>Optional properties to set on the agent.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<MqttClientAgent>
A task that represents the asynchronous operation. The task result contains the created or loaded MqttClientAgent.
Exceptions
- ArgumentException
Thrown when the name is null or empty.
- InvalidOperationException
Thrown when the agent cannot be created or loaded.