Interface ILink
A link a program sends messages over and receives them from: the loopback, MQTT, CoAP, a transport ladder, or a transport of the program's own.
public interface ILink
Remarks
A profile's node publishes each reading through SendAsync(string, ReadOnlyMemory<byte>), and a rule engine listens with SubscribeAsync(string) and ReceiveAsync(TimeSpan), so either runs over any link. Connect the link before handing it over.
Methods
ReceiveAsync(TimeSpan)
Waits a limited time for the next message on a subscribed topic.
Task<TransportMessage?> ReceiveAsync(TimeSpan timeout)
Parameters
timeoutTimeSpanHow long to wait.
Returns
- Task<TransportMessage>
The message, or
nullonce the link has ended.
Exceptions
- TimeoutException
No message arrived in time.
SendAsync(string, ReadOnlyMemory<byte>)
Publishes one message to a topic.
Task SendAsync(string topic, ReadOnlyMemory<byte> payload)
Parameters
topicstringThe destination topic.
payloadReadOnlyMemory<byte>The bytes to send.
Returns
- Task
A task that completes once the link has taken the message.
SubscribeAsync(string)
Subscribes to a topic.
Task SubscribeAsync(string topic)
Parameters
topicstringThe topic, or a filter in the syntax the link understands.
Returns
- Task
A task that completes once the subscription is placed.