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 Task HandleCall(IPacketSession session, InternalPacket packet) { var rpc = new RpcTunnel <TResponse, TRequest>(session, m_MethodInv, packet.MsgId); rpc.Start(); return(Task.Factory.StartNew(() => { using (rpc) { m_Handler .Invoke(rpc.GetReceiver(), new ServerCallContext()) .ContinueWith((taskResult) => rpc.Close(taskResult)) .Wait(); } })); }
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; } }
/// <summary> /// Construtor padrão para o reader de stream de respostas sobre o RPC informado. /// </summary> /// <param name="rpc">RPC que serve de túnel para o stream.</param> public RpcStreamReader(RpcTunnel <TSend, TReceive> rpc) { m_Rpc = rpc; m_State = ReaderState.Open; }
/// <summary> /// Construtor padrão para um stream de requisições sobre o RPC informado. /// </summary> /// <param name="rpc">RPC que serve de túnel para o stream.</param> public RpcStreamWriter(RpcTunnel <TSend, TReceive> rpc) { m_Rpc = rpc; }