checkTimeout method

ZModemEvent? checkTimeout()

Check if the current state has timed out.

Implementation

ZModemEvent? checkTimeout() {
  final timeout = _stateTimeouts[_state];
  if (timeout == null) return null;
  if (_stateEnteredAt == null) return null;
  if (clock.now().difference(_stateEnteredAt!) > timeout) {
    _enqueue(ZModemHeader.fin());
    _state = ZModemState.closed;
    _stateEnteredAt = clock.now();
    return ZTimeoutEvent(_state.name);
  }
  return null;
}