/// <summary> /// 指定された例外を処理し、実行結果を返します。 /// </summary> /// <typeparam name="TResponse">レスポンスの型</typeparam> /// <param name="call">呼び出しオブジェクト</param> /// <param name="ex">例外</param> /// <returns>実行結果</returns> private static GrpcResult <TResponse> HandleResponseException <TResponse>(AsyncUnaryCall <TResponse> call, Exception ex) { Exception actual = GrpcExceptionUtility.GetActualException(ex); GrpcCallState state; if (GrpcCallInvokerContext.TryGetState(call, out state)) { GrpcExceptionListener.NotifyCatchClientException(state.Method, state.Host, state.Options, actual); } return(GrpcResult.Create <TResponse>(actual)); }
/// <summary> /// ServerStreaming メソッドを非同期で呼び出します。 /// </summary> /// <typeparam name="TRequest">リクエストの型</typeparam> /// <typeparam name="TResponse">レスポンスの型</typeparam> /// <param name="method">メソッド</param> /// <param name="host">ホスト</param> /// <param name="options">オプション</param> /// <param name="request">リクエスト</param> /// <returns>呼び出しオブジェクト</returns> public override AsyncServerStreamingCall <TResponse> AsyncServerStreamingCall <TRequest, TResponse>(Method <TRequest, TResponse> method, string host, CallOptions options, TRequest request) { double elapsed = 0; try { method = GetCustomMethod <TRequest, TResponse>(method); OnInvokingMethod(method, host, options, request); Stopwatch watch = null; AsyncServerStreamingCall <TResponse> call; try { watch = Stopwatch.StartNew(); call = m_Invoker.AsyncServerStreamingCall(method, host, options, request); } finally { elapsed = GrpcPerformanceListener.GetMilliseconds(watch); } OnInvokedMethod(method, host, options, request, elapsed); return(GrpcCallInvokerContext.Regist <TRequest, TResponse>(call, method, host, options, m_Settings.PerformanceListener)); } catch (Exception ex) { GrpcExceptionListener.NotifyCatchClientException(method, host, options, ex); Exception alternate; if (HandleException(method, host, options, ex, out alternate)) { throw alternate; } else { throw; } } }