public void AcceptRequest(IAsyncResult ar) { IReplyChannel channel = ar.AsyncState as IReplyChannel; try { RequestContext context = channel.EndReceiveRequest(ar); channel.BeginReceiveRequest(AcceptRequest, channel); ProcessRequest(context); } catch (TimeoutException) { channel.BeginReceiveRequest(AcceptRequest, channel); } }
public void ReceiveRequest() { // Seems like this method is invoked to send a reply // with related to "already created" SOAP fault. // // It is still not understandable that this delegate // is invoked as an infinite loop ... ReplyHandler handler = delegate(Message input) { Console.Error.WriteLine("Processing a reply."); // a:InvalidSecurity // An error occurred when verifying security for the message. Assert.IsTrue(input.IsFault); throw new ApplicationException(); }; Message msg = Message.CreateMessage(MessageVersion.Default, "myAction"); RequestReceiver receiver = delegate() { return(msg); }; IChannelListener <IReplyChannel> listener = CreateListener(handler, receiver); listener.Open(); IReplyChannel reply = listener.AcceptChannel(); reply.Open(); RequestContext ctx = reply.EndReceiveRequest(reply.BeginReceiveRequest(null, null)); }
private void ChannelAccepted(IAsyncResult result) { try { IReplyChannel replyChannel = _replyChannelListener.EndAcceptChannel(result); if (replyChannel != null) { try { replyChannel.Open(); replyChannel.BeginReceiveRequest(RequestAccepted, replyChannel); } catch (Exception e) { Console.WriteLine(e); replyChannel.Abort(); } if (_replyChannelListener.State == CommunicationState.Opened) { this._replyChannelListener.BeginAcceptChannel(ChannelAccepted, _replyChannelListener); } } } catch (Exception e) { Console.WriteLine(e); this._replyChannelListener.Abort(); this._replyChannelListener = null; } }
private void DoneReplying(IAsyncResult result) { var context = (HttpContextBase)((object[])result.AsyncState)[0]; var response = (WebResponse)((object[])result.AsyncState)[1]; var serviceBusContext = (AzureServiceBusHttpContext)context; var requestContext = serviceBusContext.RequestContext; IReplyChannel replyChannel = (IReplyChannel)context.Items["ReplyChannel"]; try { requestContext.EndReply(result); } catch (Exception e) { Console.WriteLine(e); } finally { if (response != null) { response.Close(); } replyChannel.BeginReceiveRequest(RequestAccepted, replyChannel); } }
public void FullRequest() { EndpointIdentity identity = new X509CertificateEndpointIdentity(new X509Certificate2("Test/Resources/test.pfx", "mono")); EndpointAddress address = new EndpointAddress(new Uri("stream:dummy"), identity); Message mreq = Message.CreateMessage(MessageVersion.Default, "myAction"); Message mreply = null; XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; // listener setup ReplyHandler replyHandler = delegate(Message rinput) { mreply = rinput; }; RequestReceiver receiver = delegate() { return(mreq); }; IChannelListener <IReplyChannel> listener = CreateListener(replyHandler, receiver); listener.Open(); IReplyChannel reply = listener.AcceptChannel(); reply.Open(); RequestSender reqHandler = delegate(Message input) { try { // sync version somehow causes an infinite loop (!?) RequestContext ctx = reply.EndReceiveRequest(reply.BeginReceiveRequest(TimeSpan.FromSeconds(5), null, null)); // RequestContext ctx = reply.ReceiveRequest (TimeSpan.FromSeconds (5)); Console.Error.WriteLine("Acquired RequestContext."); ctx.Reply(input); } catch (Exception ex) { Console.Error.WriteLine("ERROR during processing a request in FullRequest()"); Console.Error.WriteLine(ex); Console.Error.Flush(); throw; } return(mreply); }; CustomBinding b = CreateBinding(reqHandler); IRequestChannel ch = ChannelFactory <IRequestChannel> .CreateChannel(b, address); ch.Open(); Console.Error.WriteLine("**** starting a request ****"); IAsyncResult async = ch.BeginRequest(mreq, null, null); Console.Error.WriteLine("**** request started. ****"); Message res = ch.EndRequest(async); }
public void AcceptChannel(IAsyncResult ar) { IChannelListener <IReplyChannel> listener = ar.AsyncState as IChannelListener <IReplyChannel>; IReplyChannel channel = listener.EndAcceptChannel(ar); channel.Open(); channel.BeginReceiveRequest(AcceptRequest, channel); }
void ReceiveRequest(IReplyChannel channel) { for (; ;) { IAsyncResult result = channel.BeginReceiveRequest(TimeSpan.MaxValue, this.onReceive, channel); if (!result.CompletedSynchronously) { break; } RequestContext context = channel.EndReceiveRequest(result); if (!HandleRequest(channel, context)) { break; } } }
protected override IAsyncResult BeginReceiveRequest(AsyncCallback callback, object state) { return(_innerChannel.BeginReceiveRequest(_timeout, callback, state)); }
public IAsyncResult BeginReceiveRequest(TimeSpan timeout, AsyncCallback callback, object state) { return(innerReplyChannel.BeginReceiveRequest(timeout, callback, state)); }
public override IAsyncResult BeginReceiveRequest(AsyncCallback callback, object state) { return(inner.BeginReceiveRequest(callback, state)); }
void ReceiveRequest(IReplyChannel channel) { for (; ; ) { IAsyncResult result = channel.BeginReceiveRequest(TimeSpan.MaxValue, this.onReceive, channel); if (!result.CompletedSynchronously) break; RequestContext context = channel.EndReceiveRequest(result); if (!HandleRequest(channel, context)) { break; } } }
public virtual IAsyncResult BeginReceiveRequest( TimeSpan timeout, AsyncCallback callback, object state) { return(inner.BeginReceiveRequest(timeout, callback, state)); }
public IAsyncResult BeginReceiveRequest(AsyncCallback callback, object state) => _innerChannel.BeginReceiveRequest(callback, state);
public System.IAsyncResult BeginReceiveRequest(System.TimeSpan timeout, System.AsyncCallback callback, object state) { Console.WriteLine("MyReplyChannel.BeginReceiveRequest(3)"); return(InnerChannel.BeginReceiveRequest(timeout, callback, state)); }