Example #1
0
        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));
            }
        }
Example #2
0
        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));
        }
Example #3
0
        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;
            }
        }