Example #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();
            }
        }
Example #2
0
 internal void Add(IChannel channel, ClientWaiter waiter)
 {
     _waiters[channel.GetId()] = waiter;
 }
Example #3
0
        internal bool Remove(IChannel channel, out ClientWaiter waiter)
        {
            string channelId = channel.GetId();

            return(_waiters.TryRemove(channelId, out waiter));
        }
Example #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));
        }