MemoryBroker class

An in-memory MQTT broker for tests.

Connect several MemoryTransports to one broker to make a controller and a device talk without a network:

final broker = MemoryBroker();
final controller = MemoryTransport(broker);
final device = MemoryTransport(broker);

It supports +/# filters, retained messages and last wills. Use stop and start to test what happens when the broker goes away.

Constructors

MemoryBroker()
Creates a running broker with no clients and no retained messages.

Properties

clientCount → int
How many transports are connected.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isRunning → bool
Whether new connections are accepted.
no setter
retained → Map<String, RawMessage>
The retained message of each topic.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
start() → void
Accepts connections again after stop.
stop() → void
Simulates the broker going down.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited