Exemplo n.º 1
0
        internal IAsyncResult BeginReceive(Uri destination, AsyncCallback callback, object state)
        {
            IAsyncResult result = null;

            this.ReceiveCompleteCallback = callback;
            FeedHttpConnection connection = this.GetConnection(destination);

            result = connection.BeginReceive(new AsyncCallback(OnReceiveComplete));
            return(result);
        }
Exemplo n.º 2
0
        public Feed Receive(Uri destination)
        {
            FeedHttpConnection connection = null;

            if (this.connections[destination] == null)
            {
                connection = new FeedHttpConnection(destination, serializer);
                this.connections.Add(destination, connection);
            }
            else
            {
                connection = this.connections[destination] as FeedHttpConnection;
            }

            return(connection.Receive());
        }
Exemplo n.º 3
0
        private FeedHttpConnection GetConnection(Uri destination)
        {
            FeedHttpConnection connection = null;

            lock (this.connections.SyncRoot)
            {
                connection = this.connections[destination] as FeedHttpConnection;

                if (connection == null)
                {
                    connection = new FeedHttpConnection(destination, serializer);
                    connection.ReceiveTimeout     = receiveTimeout;
                    this.connections[destination] = connection;
                }
            }

            return(connection);

            //if ((connection == null) || !connection.Connected || !connection.SocketConnected)
            //{
            //    IPEndPoint point = this.GetLocalIPEndPoint(uri);
            //    if ((point != null) && IPAddress.IsLoopback(point.Address))
            //    {
            //        connection = new SoapTcpConnection(destination, this.options, this.formatter);
            //    }
            //    else
            //    {
            //        this.PurgeConnections();
            //        Interlocked.Increment(ref this.outboundCount);
            //        connection = new SoapTcpConnection(destination, this.options, this.formatter);

            //    }
            //    this.connections[destination] = connection;
            //    //connection.BeginReceive(new AsyncCallback(this.ReceiveCallback), connection);

            //}
            //else
            //{
            //    connection.UpdateIdleTimeout();

            //}
        }
Exemplo n.º 4
0
        private void OnReceiveComplete(IAsyncResult ar)
        {
            ReceiveAsyncResult result     = ar as ReceiveAsyncResult;
            FeedHttpConnection connection = result.Connection;

            Feed feed = null;

            feed = connection.EndReceive(ar);
            FeedInputChannel channel = (FeedInputChannel)base.InputChannels[connection.Destination.ToString()];

            if (channel == null)
            {
                throw new ApplicationException("Failed to get InputChannel");
            }
            channel.Enqueue(feed);

            FeedAsyncResult feedResult = new FeedAsyncResult(channel);

            this.ReceiveCompleteCallback(feedResult);
        }
Exemplo n.º 5
0
 public ReceiveAsyncResult(FeedHttpConnection connection, Stream stream)
 {
     this.connection = connection;
     this.stream     = stream;
 }