onDataReceived method

  1. @override
void onDataReceived(
  1. Uint8List data
)

Is called when data is received

Implementation

@override
void onDataReceived(Uint8List data) {
  _uint8listReader.add(data);
  final lines = _uint8listReader.readLines();
  if (lines == null) {
    return;
  }
  // RFC 5321 section 4.2: a multi-line reply consists of `NNN-text` lines
  // and ends with a `NNN text` (or bare `NNN`) line. The lines of a reply
  // may arrive in separate chunks, so collect them until the final line.
  for (final line in lines) {
    if (line.isEmpty) {
      continue;
    }
    _pendingReplyLines.add(line);
    if (_isFinalReplyLine(line)) {
      final reply = List<String>.of(_pendingReplyLines);
      _pendingReplyLines.clear();
      onServerResponse(reply);
    }
  }
}