createCall<Q, R> method

  1. @override
ClientCall<Q, R> createCall<Q, R>(
  1. ClientMethod<Q, R> method,
  2. Stream<Q> requests,
  3. CallOptions options
)

Initiates a new RPC on this connection.

Implementation

@override
ClientCall<Q, R> createCall<Q, R>(ClientMethod<Q, R> method, Stream<Q> requests, CallOptions options) {
  final call = MyClientCall<Q, R>(
    method,
    requests,
    options,
  );
  // do the call
  final serviceName = method.path.split('/')[1];
  final methodName = method.path.split('/')[2];
  requests.first.then((request) {
    final requestData = (request as GeneratedMessage).writeToBuffer();
    embeddingChannel
        .invoke(serviceName, data: {'name': serviceName, 'method': methodName, 'data': requestData}).then((response) {
      try {
        final responseData = method.responseDeserializer(response!);
        call.setResponse(responseData);
      } catch (e, stackTrace) {
        debugPrint('error: $e');
        debugPrint('stackTrace: $stackTrace');
      }
    });
  });
  return call;
}