コード例 #1
0
        internal async Task <PollResponse> Poll(PollRequest request, string clientId)
        {
            var pbReq    = request.ValidateAndComplete(_clientId);
            var response = new PollResponse(request);

            _pendingRequests.TryAdd(response.RequestId, response);
            SendRequest(pbReq);
            await response.WaitForResponseTask.Task;

            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new Exception($"poll request error: {response.Error}");
            }
            return(response);
        }
コード例 #2
0
        /// <summary>
        /// Poll a list of messages from a queue
        /// </summary>
        /// <param name="request">Poll request object</param>
        public async Task <PollResponse> Poll(PollRequest request)
        {
            Downstream downstream;
            bool       connected;

            lock (_downstreamSyncLock)
            {
                downstream = _downstream;
                connected  = _connected;
            }

            if (connected && downstream != null)
            {
                return(await downstream.Poll(request, _clientId));
            }
            else
            {
                if (ctx.IsCancellationRequested)
                {
                    throw new Exception("queue client closed");
                }
                throw new Exception("queue client connection is not ready");
            }
        }