internal override Message RequestCorrelated(Message msg, TimeSpan timeout, IOutputChannel channel) { DateTime startTime = DateTime.Now; Message ret = null; ManualResetEvent wait = new ManualResetEvent(false); Action <Message> handler = delegate(Message reply) { ret = reply; wait.Set(); }; ReplyHandlerQueue.Enqueue(handler); channel.Send(msg, timeout); if (ret == null && !wait.WaitOne(timeout - (DateTime.Now - startTime))) { throw new TimeoutException(); } return(ret); }
void ProcessInputCore(IInputChannel input, Message message) { bool isReply = message != null && Contract.Operations.Any(od => (od.DeclaringContract.CallbackContractType == od.DeclaringContract.ContractType || !od.InCallbackContract) && od.Messages.Any(md => md.Action == message.Headers.Action)); if (isReply) { if (ReplyHandlerQueue.Count > 0) { if (isReply) { var h = ReplyHandlerQueue.Dequeue(); h(message); return; } } } if (!MessageMatchesEndpointDispatcher(message, Runtime.CallbackDispatchRuntime.EndpointDispatcher)) { throw new EndpointNotFoundException(String.Format("The request message has the target '{0}' with action '{1}' which is not reachable in this service contract", message.Headers.To, message.Headers.Action)); } new InputOrReplyRequestProcessor(Runtime.CallbackDispatchRuntime, input).ProcessInput(message); }
void ProcessInputCore(IInputChannel input, Message message) { bool isReply = message != null && Contract.Operations.Any(od => (od.DeclaringContract.CallbackContractType == od.DeclaringContract.ContractType || !od.InCallbackContract) && od.Messages.Any(md => md.Action == message.Headers.Action)); if (isReply) { if (ReplyHandlerQueue.Count > 0) { if (isReply) { var h = ReplyHandlerQueue.Dequeue(); h(message); return; } } } if (message.IsFault) { Exception ex; var mf = MessageFault.CreateFault(message, 0x10000); if (FaultConverter.GetDefaultFaultConverter(message.Version).TryCreateException(message, mf, out ex)) // FIXME: get maxMessageSize somehow { throw ex; } else { throw new FaultException(mf); } } if (!MessageMatchesEndpointDispatcher(message, Runtime.CallbackDispatchRuntime.EndpointDispatcher)) { throw new EndpointNotFoundException(String.Format("The request message has the target '{0}' with action '{1}' which is not reachable in this service contract", message.Headers.To, message.Headers.Action)); } new InputOrReplyRequestProcessor(Runtime.CallbackDispatchRuntime, input).ProcessInput(message); }