Table of Contents

Class LoopbackTransport

Namespace
Pamoja.Loopback
Assembly
Pamoja.Loopback.dll

One in-process link to a broker.

public sealed class LoopbackTransport : ILink, IDisposable
Inheritance
LoopbackTransport
Implements
Inherited Members

Remarks

Calls on one link run one at a time, so a send made while a receive is waiting runs once the receive returns. A task that listens should have a link of its own.

Methods

ConnectAsync()

Marks this link connected so it will carry traffic.

public Task ConnectAsync()

Returns

Task

Remarks

A link that was disconnected keeps its subscriptions when it connects again.

Exceptions

PamojaException

The native call failed.

DisconnectAsync()

Marks this link disconnected, so sends over it fail.

public Task DisconnectAsync()

Returns

Task

Remarks

Messages queued for it are dropped; its subscriptions are kept.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

IsConnectedAsync()

Reports whether this link is connected.

public Task<bool> IsConnectedAsync()

Returns

Task<bool>

true when connected.

ReceiveAsync()

Waits for the next message on a subscribed topic.

public Task<TransportMessage?> ReceiveAsync()

Returns

Task<TransportMessage>

The message.

Remarks

A connected link never ends on its own, so this waits until a message arrives. Use ReceiveAsync(TimeSpan) to stop waiting.

Exceptions

PamojaException

The link is not connected.

ReceiveAsync(TimeSpan)

Waits a limited time for the next message on a subscribed topic.

public Task<TransportMessage?> ReceiveAsync(TimeSpan timeout)

Parameters

timeout TimeSpan

How long to wait.

Returns

Task<TransportMessage>

The message.

Remarks

When the time runs out nothing is lost: a message arriving afterwards waits for the next receive.

Exceptions

TimeoutException

No message arrived in time.

PamojaException

The link is not connected.

SendAsync(string, ReadOnlyMemory<byte>)

Publishes a payload to a topic on the broker.

public Task SendAsync(string topic, ReadOnlyMemory<byte> payload)

Parameters

topic string

The destination topic.

payload ReadOnlyMemory<byte>

The bytes to publish.

Returns

Task

Exceptions

PamojaException

The link is not connected.

SendAsync(string, string)

Publishes text to a topic on the broker: words, or a number written out.

public Task SendAsync(string topic, string text)

Parameters

topic string

The destination topic.

text string

The text to publish, as UTF-8.

Returns

Task

Exceptions

PamojaException

The link is not connected.

SubscribeAsync(string)

Subscribes this link to a topic.

public Task SubscribeAsync(string topic)

Parameters

topic string

The topic to subscribe to.

Returns

Task

Exceptions

PamojaException

The link is not connected.