Пример #1
0
        internal async Task <NotHttpConnection> GetRequestConnection(NHClientRequest caller)
        {
            NHClientEndpoint         endpoint;
            Task <NotHttpConnection> blockTask;

            lock (this)
            {
                Uri url = caller.Url;

                Dictionary <int, NHClientEndpoint> hostPorts;
                if (!connections.TryGetValue(url.Host, out hostPorts))
                {
                    hostPorts = new Dictionary <int, NHClientEndpoint>();
                    connections.Add(url.Host, hostPorts);
                }

                if (!hostPorts.TryGetValue(url.Port, out endpoint))
                {
                    endpoint = new NHClientEndpoint(url.Host, url.Port, isOverlapped, maxConnections, idleTimeout, logger);
                    hostPorts.Add(url.Port, endpoint);
                }

                blockTask = endpoint.WaitForRequestSlot(caller);
            }

            return(await blockTask);
        }
Пример #2
0
 public NotHttpConnection(NHClientEndpoint ep)
 {
     endpoint            = ep;
     receivedResponses   = new Dictionary <int, NHClientResponse>();
     pendingClients      = new Dictionary <int, TaskCompletionSource <IHttpResponse> >();
     sequenceNumber      = 0;
     outstandingRequests = 0;
     idleTask            = new TaskCompletionSource <bool>();
 }