Future close()

Closes the protocol.

This will clear all remaining work and shutdown then onAction stream.

Returns a future which completes when all work is done.

Source

Future close() async {
  log('closing');
  for (var work in _ackQueue..addAll(_waitQueue)) {
    log('  outstanding work: $work');
    work.completer.complete(false);
  }
  log('clearing queues');
  _ackQueue.clear();
  _waitQueue.clear();
  _bytesOut = 0;
  _errorHoldoff = null;
  log('closing knob controller');
  _knobAction.close();
  log('canceling serial');
  await _sub.cancel();
}