readAll method
Guarantees that all of length bytes are actually read off the transport.
Returns the number of bytes actually read, which must be equal to
length.
Throws TTransportError if there was an error reading data
Implementation
int readAll(Int8List buffer, int offset, int length) {
int got = 0;
int ret = 0;
while (got < length) {
ret = read(buffer, offset + got, length - got);
if (ret <= 0) {
throw TTransportError(
TTransportErrorType.UNKNOWN,
"Cannot read. Remote side has closed. Tried to read $length "
"bytes, but only got $got bytes.");
}
got += ret;
}
return got;
}