Exemplo n.º 1
0
        private object GetReturnValue(RpcRequest request)
        {
            ClientWaiter waiter  = new ClientWaiter(_timeOut);
            IChannel     channel = CreateChannel();

            try
            {
                RpcResponse response = GerResponseFromServer(channel, request, waiter);
                return(GetMethodResult(request.MethodName, response));
            }
            catch (OperationCanceledException)
            {
                RemoveWaiter(channel);
                channel?.CloseAsync();
                throw;
            }
            catch (Exception)
            {
                RemoveWaiter(channel);
                throw;
            }
            finally
            {
                waiter.Dispose();
            }
        }
Exemplo n.º 2
0
 internal void Add(IChannel channel, ClientWaiter waiter)
 {
     _waiters[channel.GetId()] = waiter;
 }
Exemplo n.º 3
0
        internal bool Remove(IChannel channel, out ClientWaiter waiter)
        {
            string channelId = channel.GetId();

            return(_waiters.TryRemove(channelId, out waiter));
        }
Exemplo n.º 4
0
        private RpcResponse GerResponseFromServer(IChannel channel, RpcRequest request, ClientWaiter waiter)
        {
            _clientInvoker.Add(channel, waiter);
            IByteBuffer buffer = Unpooled.WrappedBuffer(_rpcSerializer.ToBytes(request));

            channel.WriteAndFlushAsync(buffer);
            waiter.Wait();
            _channelPool.Return(channel);
            return(_rpcSerializer.ToObject <RpcResponse>(waiter.Bytes));
        }