findPrevious method

  1. @override
CoapExchange? findPrevious(
  1. int? key,
  2. CoapExchange exchange
)
override

Checks if the specified key is already associated with a previous exchange and otherwise associates the key with the exchange specified.

Implementation

@override
CoapExchange? findPrevious(final int? key, final CoapExchange exchange) {
  CoapExchange? prev;
  if (_maps[_first].containsKey(key)) {
    prev = _maps[_first][key];
  }
  _maps[_first][key] = exchange;
  if (prev != null || _first == _second) {
    return prev;
  }
  if (_maps[_second].containsKey(key)) {
    prev = _maps[_second][key];
  }
  _maps[_second][key] = exchange;
  return prev;
}