sendRequestKeepingProgress<T extends Result?> method

  1. @protected
Future<T> sendRequestKeepingProgress<T extends Result?>(
  1. String methodName, [
  2. Request? request
])
inherited

Sends request to the peer like sendRequest does, but leaves any progress stream for it open.

This is for a caller that sends several requests under one progress token, such as an input_required retry. That caller owns the token and hands it back with closeProgress once it stops sending. Throws a StateError after the handler's request is cancelled, since nothing it sends can reach the peer any more.

Implementation

@protected
Future<T> sendRequestKeepingProgress<T extends Result?>(
  String methodName, [
  Request? request,
]) async {
  final currentRequest = Zone.current[_currentRequestKey];
  if (currentRequest is _IncomingRequest && currentRequest.cancelled) {
    throw StateError(
      'The request that started this operation was cancelled.',
    );
  }
  return ((await _peer.sendRequest(methodName, request)) as Map?)
          ?.cast<String, Object?>()
      as T;
}