track method

void track(
  1. String requestId,
  2. String method, {
  3. int? timeoutMs,
})

Start tracking a request. Call this right before sending the request.

If a timer already exists for requestId, it is replaced (the old timer is cancelled).

Implementation

void track(String requestId, String method, {int? timeoutMs}) {
  // Cancel any existing timer for this ID (defensive).
  _timers[requestId]?.cancel();

  final timeout = timeoutMs ?? defaultTimeoutMs;
  _timers[requestId] = Timer(Duration(milliseconds: timeout), () {
    _timers.remove(requestId);
    onTimeout(method, requestId, timeout);
  });
}