MultiChannel<T> class
abstract
A class that multiplexes multiple virtual channels across a single underlying transport layer.
This should be connected to another MultiChannel on the other end of the underlying channel. It starts with a single default virtual channel, accessible via stream and sink. Additional virtual channels can be created with virtualChannel.
When a virtual channel is created by one endpoint, the other must connect to it before messages may be sent through it. The first endpoint passes its VirtualChannel.id to the second, which then creates a channel from that id also using virtualChannel. For example:
// First endpoint
var virtual = multiChannel.virtualChannel();
multiChannel.sink.add({
"channel": virtual.id
});
// Second endpoint
multiChannel.stream.listen((message) {
var virtual = multiChannel.virtualChannel(message["channel"]);
// ...
});
Sending errors across a MultiChannel is not supported. Any errors from the underlying stream will be reported only via the default MultiChannel.stream.
Each virtual channel may be closed individually. When all of them are closed, the underlying StreamSink is closed automatically.
- Implemented types
- Implementers
Constructors
- MultiChannel(StreamChannel inner)
-
Creates a new MultiChannel that sends and receives messages over
inner
.factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sink
→ StreamSink<
T> -
The default output stream.
no setteroverride
-
stream
→ Stream<
T> -
The default input stream.
no setteroverride
Methods
-
cast<
S> () → StreamChannel< S> -
Returns a copy of this with the generic type coerced to
S
.inherited -
changeSink(
StreamSink< T> change(StreamSink<T> )) → StreamChannel<T> -
Returns a copy of this with sink replaced by
change
's return value.inherited -
changeStream(
Stream< T> change(Stream<T> )) → StreamChannel<T> -
Returns a copy of this with stream replaced by
change
's return value.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pipe(
StreamChannel< T> other) → void -
Connects this to
other
, so that any values emitted by either are sent directly to the other.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
transform<
S> (StreamChannelTransformer< S, T> transformer) → StreamChannel<S> -
Transforms this using
transformer
.inherited -
transformSink(
StreamSinkTransformer< T, T> transformer) → StreamChannel<T> -
Transforms only the sink component of this using
transformer
.inherited -
transformStream(
StreamTransformer< T, T> transformer) → StreamChannel<T> -
Transforms only the stream component of this using
transformer
.inherited -
virtualChannel(
[int? id]) → VirtualChannel< T> - Creates a new virtual channel.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited