public async Task <IServiceChannelDispatcher> CreateServiceChannelDispatcherAsync(IChannel channel) { ServiceChannel.SessionIdleManager sessionIdleManager = channel.GetProperty <ServiceChannel.SessionIdleManager>(); IChannelBinder binder = null; if (channel is IReplyChannel) { ReplyChannelBinder rcbinder = channel.GetProperty <ReplyChannelBinder>(); rcbinder.Init(channel as IReplyChannel, BaseAddress); binder = rcbinder; } else if (channel is IDuplexSessionChannel) { DuplexChannelBinder dcbinder = channel.GetProperty <DuplexChannelBinder>(); dcbinder.Init(channel as IDuplexSessionChannel, _requestReplyCorrelator, BaseAddress); binder = dcbinder; } else if (channel is IInputChannel) { InputChannelBinder icbinder = channel.GetProperty <InputChannelBinder>(); icbinder.Init(channel as IInputChannel, BaseAddress); binder = icbinder; } // TODO: Wire up wasChannelThrottled var channelHandler = new ChannelHandler(Binding.MessageVersion, binder, channel.GetProperty <ServiceThrottle>(), this, /*wasChannelThrottled*/ false, sessionIdleManager); IServiceChannelDispatcher channelDispatcher = channelHandler.GetDispatcher(); // channel.ChannelDispatcher = channelDispatcher; await channelHandler.OpenAsync(); return(channelDispatcher); }
internal ChannelHandler(MessageVersion messageVersion, IChannelBinder binder, ServiceThrottle throttle, ServiceDispatcher serviceDispatcher, bool wasChannelThrottled, SessionIdleManager idleManager) { ChannelDispatcher channelDispatcher = serviceDispatcher.ChannelDispatcher; _serviceDispatcher = serviceDispatcher; _messageVersion = messageVersion; _isManualAddressing = channelDispatcher.ManualAddressing; _binder = binder; _throttle = throttle; _wasChannelThrottled = wasChannelThrottled; _host = channelDispatcher.Host; _duplexBinder = binder as DuplexChannelBinder; _hasSession = binder.HasSession; _isConcurrent = ConcurrencyBehavior.IsConcurrent(channelDispatcher, _hasSession); // TODO: Work out if MultipleReceiveBinder is necessary //if (channelDispatcher.MaxPendingReceives > 1) //{ // // We need to preserve order if the ChannelHandler is not concurrent. // this.binder = new MultipleReceiveBinder( // this.binder, // channelDispatcher.MaxPendingReceives, // !this.isConcurrent); //} if (channelDispatcher.BufferedReceiveEnabled) { _binder = new BufferedReceiveBinder(_binder); } _idleManager = idleManager; if (_binder.HasSession) { _sessionOpenNotification = _binder.Channel.GetProperty <SessionOpenNotification>(); _needToCreateSessionOpenNotificationMessage = _sessionOpenNotification != null && _sessionOpenNotification.IsEnabled; } //_requestInfo = new RequestInfo(this); // TODO: Wire up lifetime management in place of listener state //if (this.listener.State == CommunicationState.Opened) //{ _serviceDispatcher.ChannelDispatcher.Channels.IncrementActivityCount(); _incrementedActivityCountInConstructor = true; //} }
internal AsyncDuplexRequest(DuplexChannelBinder parent) { _parent = parent; }
internal DuplexRequestContext(IDuplexChannel channel, Message request, DuplexChannelBinder binder) : base(request, binder.DefaultCloseTimeout, binder.DefaultSendTimeout) { _channel = channel; _binder = binder; }
void Dispatch() { ListenerChannel channel = this.channel; SessionIdleManager idleManager = this.idleManager; this.channel = null; this.idleManager = null; try { if (channel != null) { ChannelHandler handler = new ChannelHandler(listenerBinder.MessageVersion, channel.Binder, /*this.throttle,*/ this, /*(channel.Throttle != null),*/ /*this.wrappedTransaction,*/ idleManager); if (!channel.Binder.HasSession) { //channelDispatcher.Channels.Add(channel.Binder.Channel); } if (channel.Binder is DuplexChannelBinder) { DuplexChannelBinder duplexChannelBinder = channel.Binder as DuplexChannelBinder; duplexChannelBinder.ChannelHandler = handler; duplexChannelBinder.DefaultCloseTimeout = DefaultCloseTimeout; if (timeouts == null) { duplexChannelBinder.DefaultSendTimeout = ServiceDefaults.SendTimeout; } else { duplexChannelBinder.DefaultSendTimeout = timeouts.SendTimeout; } } ChannelHandler.Register(handler); channel = null; idleManager = null; } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } HandleError(e); } finally { if (channel != null) { channel.Binder.Channel.Abort(); //if (this.throttle != null && this.channelDispatcher.Session) //{ // this.throttle.DeactivateChannel(); //} if (idleManager != null) { idleManager.CancelTimer(); } } } }