public override TResponse BlockingUnaryCall <TRequest, TResponse>(Method <TRequest, TResponse> method, string host, CallOptions options, TRequest request) { var session = m_channel.GetSession(); using (var rpc = new RpcTunnel <TRequest, TResponse>(session, method)) { rpc.StartRequest(request); return(TaskUtil.GetResult(rpc.ReturnValueAsync(), options.CancellationToken)); } }
public override AsyncUnaryCall <TResponse> AsyncUnaryCall <TRequest, TResponse>(Method <TRequest, TResponse> method, string host, CallOptions options, TRequest request) { var session = m_channel.GetSession(); var call = Task.Factory.StartNew(() => { using (var rpc = new RpcTunnel <TRequest, TResponse>(session, method)) { rpc.StartRequest(request); return(TaskUtil.GetResult(rpc.ReturnValueAsync(), options.CancellationToken)); } }); return(new AsyncUnaryCall <TResponse>(call)); }
public override AsyncServerStreamingCall <TResponse> AsyncServerStreamingCall <TRequest, TResponse>(Method <TRequest, TResponse> method, string host, CallOptions options, TRequest request) { var session = m_channel.GetSession(); var rpc = new RpcTunnel <TRequest, TResponse>(session, method); var ret = new AsyncServerStreamingCallImpl <TRequest, TResponse>(rpc, session, method); try { // Send request rpc.StartRequest(request); // Wait response return(ret); } catch (Exception) { // Failed to request: unregister rpc ret.Dispose(); throw; } }