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); }
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()); }
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(); //} }
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); }
public ReceiveAsyncResult(FeedHttpConnection connection, Stream stream) { this.connection = connection; this.stream = stream; }