onAck method

void onAck(
  1. int ackId
)

Implementation

void onAck(int ackId) {
  if (waitingValues!.isEmpty) {
    return;
  }
  var valueRemoved = false;
  if (!waitingValues!.isEmpty && waitingValues!.first.waitingAck != ackId) {
    ValueUpdate? matchUpdate;
    for (var update in waitingValues!) {
      if (update.waitingAck == ackId) {
        matchUpdate = update;
        break;
      }
    }

    if (matchUpdate != null) {
      while (!waitingValues!.isEmpty && waitingValues!.first != matchUpdate) {
        var removed = waitingValues!.removeFirst();
        if (_storage != null) {
          _storage!.removeValue(removed);
          valueRemoved = true;
        }
      }
    }
  }

  while (!waitingValues!.isEmpty &&
      waitingValues!.first.waitingAck == ackId) {
    var removed = waitingValues!.removeFirst();
    if (_storage != null) {
      _storage!.removeValue(removed);
      valueRemoved = true;
    }
  }

  if (valueRemoved && _storage != null) {
    _storage!.valueRemoved(waitingValues!);
  }
}