StreamBuffer<T> class

Allow orderly reading of elements from a datastream, such as Socket, which might not receive List<int> bytes regular chunks.

Example usage:

StreamBuffer<int> buffer = StreamBuffer();
Socket.connect('127.0.0.1', 5555).then((sock) => sock.pipe(buffer));
buffer.read(100).then((bytes) {
  // do something with 100 bytes;
});

Throws UnderflowError if throwOnError is true. Useful for unexpected Socket disconnects.

Implemented types

Constructors

StreamBuffer({bool throwOnError = false, int limit = 0})
Create a stream buffer with optional, soft limit to the amount of data the buffer will hold before pausing the underlying stream. A limit of 0 means no buffer limits.

Properties

buffered int
The amount of unread data buffered.
no setter
hashCode int
The hash code for this object.
no setterinherited
limit int
getter/setter pair
limited bool
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addStream(Stream<List<T>> stream) Future
Consumes the elements of stream.
override
close() Future
Tells the consumer that no further streams will be added.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read(int size) Future<List<T>>
Read fully size bytes from the stream and return in the future.
toString() String
A string representation of this object.
inherited

Operators

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