MemoryTransport class final

An in-memory transport used for tests and as the basis for mock brokers.

close is a local teardown (the incoming stream is closed with done). To simulate a peer drop, call injectError or injectDone — the same events a real socket surfaces through onError.

Implemented types

Constructors

MemoryTransport()

Properties

hashCode → int
The hash code for this object.
no setterinherited
incoming → Stream<Uint8List>
Chunks of bytes received from the peer.
no setteroverride
isClosed → bool
Whether close was called and the transport cannot be reused.
no setter
isConnected → bool
Whether the transport is currently connected.
no setteroverride
outgoing → List<Uint8List>
Bytes written by the client (what the peer would receive).
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(Uint8List data) → void
Queues data for sending to the peer.
override
close() → Future<void>
Closes the transport.
override
connect() → Future<void>
Establishes the underlying connection.
override
flush() → Future<void>
Flushes any buffered outbound data.
override
inject(Uint8List data) → void
Simulates bytes arriving from the peer.
injectDone() → void
Simulates a clean peer FIN: the socket reports an error rather than just closing the stream, matching MqttSocketTransport.
injectError(Object error, [StackTrace? stackTrace]) → void
Simulates a connection failure by emitting error to the incoming stream, as a real transport would on socket error.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
takeOutgoing() → List<Uint8List>
Returns and clears all queued outgoing chunks.
takeOutgoingBytes() → Uint8List
Concatenates all queued outgoing chunks into a single buffer.
toString() → String
A string representation of this object.
inherited

Operators

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