2 using System.Collections.Generic;
3 using System.ServiceModel;
4 using System.ServiceModel.Channels;
5 using System.ServiceModel.Security;
6 using System.ServiceModel.Security.Tokens;
8 using System.ServiceModel.MonoInternal;
10 namespace System.ServiceModel.Dispatcher
12 // Its lifetime is per-call.
13 // ServiceRuntimeChannel's lifetime is per-session.
14 internal class InputOrReplyRequestProcessor : BaseRequestProcessor
16 DispatchRuntime dispatch_runtime;
17 IChannel reply_or_input;
18 IContextChannel context_channel;
20 public InputOrReplyRequestProcessor (DispatchRuntime runtime, IChannel replyOrInput)
22 Init (runtime, replyOrInput);
25 InitializeChain.AddHandler (new InitializingHandler ());
28 ProcessingChain.AddHandler (new PostReceiveRequestHandler ()).
29 AddHandler (new OperationInvokerHandler (replyOrInput));
32 ErrorChain.AddHandler (new ErrorProcessingHandler (replyOrInput));
35 FinalizationChain.AddHandler (new FinalizeProcessingHandler ());
38 void Init (DispatchRuntime runtime, IChannel replyOrInput)
40 dispatch_runtime = runtime;
41 reply_or_input = replyOrInput;
44 public void ProcessInput (Message message)
46 OperationContext opcx = CreateOperationContext (message);
47 ProcessRequest (new MessageProcessingContext (opcx, reply_or_input));
50 public void ProcessReply (RequestContext rc)
52 OperationContext opcx = CreateOperationContext (rc.RequestMessage);
53 opcx.RequestContext = rc;
54 ProcessRequest (new MessageProcessingContext (opcx, reply_or_input));
57 OperationContext CreateOperationContext (Message incoming)
59 IContextChannel contextChannel;
60 if (dispatch_runtime.CallbackClientRuntime.CallbackClientType != null) {
61 #if DISABLE_REAL_PROXY
62 var type = ServiceProxyGenerator.CreateCallbackProxyType (dispatch_runtime, dispatch_runtime.CallbackClientRuntime.CallbackClientType);
63 contextChannel = (ServiceRuntimeChannel) Activator.CreateInstance (type, new object [] {reply_or_input, dispatch_runtime});
65 contextChannel = (IContextChannel) new ClientRealProxy (dispatch_runtime.CallbackClientRuntime.CallbackClientType, new DuplexServiceRuntimeChannel (reply_or_input, dispatch_runtime), true).GetTransparentProxy ();
69 contextChannel = new ServiceRuntimeChannel (reply_or_input, dispatch_runtime);
70 contextChannel.Open (); // FIXME: timeout?
71 OperationContext opCtx = new OperationContext (contextChannel);
72 opCtx.IncomingMessage = incoming;
73 opCtx.EndpointDispatcher = dispatch_runtime.EndpointDispatcher;
74 context_channel = contextChannel;