BufferedP2PStreamReader class

A pull-based reader for P2PStream that only reads what's requested.

This is critical for circuit relay to prevent data loss. The eager StreamController-based adapters would over-read data meant for relay forwarding, causing it to be stuck in internal buffers and lost.

BufferedP2PStreamReader:

  • Only reads from P2PStream when data is actually requested
  • Exposes remaining unconsumed bytes via remainingBuffer
  • Supports conversion to Stream<List

Constructors

BufferedP2PStreamReader(P2PStream _stream)

Properties

hashCode int
The hash code for this object.
no setterinherited
hasRemainingData bool
Check if there are bytes remaining in the buffer
no setter
isClosed bool
Check if the reader is closed
no setter
isEOF bool
Check if the reader has reached EOF
no setter
remainingBuffer Uint8List
Get remaining unconsumed bytes in buffer. This is critical for relay: after reading handshake messages, any buffered application data must be forwarded to the relay peer.
no setter
remainingLength int
Number of bytes remaining in buffer
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

asStream() Stream<List<int>>
Adapt this buffered reader to a Stream<List
close() → void
Close the buffered reader
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readByte() Future<int>
Read a single byte from the stream
readExact(int length) Future<Uint8List>
Read exactly length bytes from the stream. Throws if EOF is reached before reading length bytes.
readVarint() Future<int>
Read a varint from the stream (for length-delimited messages).
toString() String
A string representation of this object.
inherited

Operators

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