public override IChannelListener <TChannel> BuildChannelListener <TChannel>(ChannelDemuxerFilter filter) where TChannel : class, IChannel { LayeredChannelListener <TChannel> listener = this.CreateListener <TChannel>(filter); listener.InnerChannelListener = this.innerListener; return(listener); }
public OpenAsyncResult(DatagramChannelDemuxer <TInnerChannel, TInnerItem> channelDemuxer, ChannelDemuxerFilter filter, IChannelListener listener, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { this.channelDemuxer = channelDemuxer; this.filter = filter; this.listener = listener; this.timeoutHelper = new TimeoutHelper(timeout); if (this.channelDemuxer.openSemaphore.EnterAsync(this.timeoutHelper.RemainingTime(), DatagramChannelDemuxer <TInnerChannel, TInnerItem> .OpenAsyncResult.waitOverCallback, this)) { bool flag = false; bool flag2 = false; try { flag2 = this.OnWaitOver(); flag = true; } finally { if (!flag) { this.Cleanup(); } } if (flag2) { this.Cleanup(); base.Complete(true); } } }
public void OnOuterListenerOpen(ChannelDemuxerFilter filter, IChannelListener listener, TimeSpan timeout) { TimeoutHelper helper = new TimeoutHelper(timeout); this.openSemaphore.Enter(helper.RemainingTime()); try { if (this.ShouldStartAccepting(filter, listener)) { try { this.innerListener.Open(helper.RemainingTime()); this.StartAccepting(true); lock (this.ThisLock) { if (this.abortOngoingOpen) { this.innerListener.Abort(); } } return; } catch (Exception exception) { this.pendingExceptionOnOpen = exception; throw; } } this.ThrowPendingOpenExceptionIfAny(); } finally { this.openSemaphore.Exit(); } }
public void OnOuterListenerAbort(ChannelDemuxerFilter filter) { if (this.ShouldCloseInnerListener(filter, true)) { this.innerListener.Abort(); } }
public override IChannelListener <TChannel> BuildChannelListener <TChannel>(ChannelDemuxerFilter filter) where TChannel : class, IChannel { return(new InputQueueChannelListener <TChannel>(filter, this) { InnerChannelListener = this.innerListener }); }
internal InternalDuplexChannelFactory(InternalDuplexBindingElement bindingElement, BindingContext context, InputChannelDemuxer channelDemuxer, IChannelFactory <IOutputChannel> innerChannelFactory, LocalAddressProvider localAddressProvider) : base(context.Binding, innerChannelFactory) { this.channelDemuxer = channelDemuxer; this.innerChannelFactory = innerChannelFactory; ChannelDemuxerFilter filter = new ChannelDemuxerFilter(new MatchNoneMessageFilter(), -2147483648); this.innerChannelListener = this.channelDemuxer.BuildChannelListener <IInputChannel>(filter); this.localAddressProvider = localAddressProvider; this.providesCorrelation = bindingElement.ProvidesCorrelation; }
public override IChannelListener <TChannel> BuildChannelListener <TChannel>(BindingContext context) where TChannel : class, IChannel { if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } ChannelDemuxerFilter filter = context.BindingParameters.Remove <ChannelDemuxerFilter>(); this.SubstituteCachedBindingContextParametersIfNeeded(context); if (filter == null) { return(this.demuxer.BuildChannelListener <TChannel>(context)); } return(this.demuxer.BuildChannelListener <TChannel>(context, filter)); }
private bool ShouldOpenInnerListener(ChannelDemuxerFilter filter, IChannelListener listener) { lock (this.ThisLock) { if ((listener.State == CommunicationState.Closed) || (listener.State == CommunicationState.Closing)) { return(false); } this.filterTable.Add(filter.Filter, listener, filter.Priority); if (++this.openCount == 1) { this.abortOngoingOpen = false; return(true); } } return(false); }
private bool ShouldCloseInnerListener(ChannelDemuxerFilter filter, bool aborted) { lock (this.ThisLock) { if (this.filterTable.ContainsKey(filter.Filter)) { this.filterTable.Remove(filter.Filter); if (--this.openCount == 0) { if (aborted) { this.abortOngoingOpen = true; } return(true); } } } return(false); }
public void OnOuterListenerClose(ChannelDemuxerFilter filter, TimeSpan timeout) { if (this.ShouldCloseInnerListener(filter, false)) { bool flag = false; try { this.innerListener.Close(timeout); flag = true; } finally { if (!flag) { this.innerListener.Abort(); } } } }
public IAsyncResult OnBeginOuterListenerClose(ChannelDemuxerFilter filter, TimeSpan timeout, AsyncCallback callback, object state) { bool flag = false; lock (this.ThisLock) { if (this.filterTable.ContainsKey(filter.Filter)) { this.filterTable.Remove(filter.Filter); if (--this.openCount == 0) { flag = true; } } } if (!flag) { return(new CompletedAsyncResult(callback, state)); } return(new CloseAsyncResult <TInnerChannel, TInnerItem>((DatagramChannelDemuxer <TInnerChannel, TInnerItem>) this, timeout, callback, state)); }
public void OnOuterListenerAbort(ChannelDemuxerFilter filter) { bool flag = false; lock (this.ThisLock) { if (this.filterTable.ContainsKey(filter.Filter)) { this.filterTable.Remove(filter.Filter); if (--this.openCount == 0) { flag = true; this.abortOngoingOpen = true; } } } if (flag) { this.AbortState(); } }
public IAsyncResult OnBeginOuterListenerClose(ChannelDemuxerFilter filter, TimeSpan timeout, AsyncCallback callback, object state) { if (this.ShouldCloseInnerListener(filter, false)) { bool flag = false; try { IAsyncResult result = this.innerListener.BeginClose(timeout, callback, state); flag = true; return(result); } finally { if (!flag) { this.innerListener.Abort(); } } } return(new CompletedAsyncResult(callback, state)); }
public IDuplexChannel CreateChannel(EndpointAddress remoteAddress, Uri via, EndpointAddress localAddress, MessageFilter filter, int priority, bool usesUniqueHeader) { ChannelDemuxerFilter demuxFilter = new ChannelDemuxerFilter(new AndMessageFilter(new EndpointAddressMessageFilter(localAddress, true), filter), priority); IDuplexChannel newChannel = null; IOutputChannel innerOutputChannel = null; IChannelListener <IInputChannel> innerInputListener = null; IInputChannel innerInputChannel = null; try { innerOutputChannel = this.innerChannelFactory.CreateChannel(remoteAddress, via); innerInputListener = this.channelDemuxer.BuildChannelListener <IInputChannel>(demuxFilter); innerInputListener.Open(); innerInputChannel = innerInputListener.AcceptChannel(); newChannel = new ClientCompositeDuplexChannel(this, innerInputChannel, innerInputListener, localAddress, innerOutputChannel, usesUniqueHeader); } finally { if (newChannel == null) // need to cleanup { if (innerOutputChannel != null) { innerOutputChannel.Close(); } if (innerInputListener != null) { innerInputListener.Close(); } if (innerInputChannel != null) { innerInputChannel.Close(); } } } return(newChannel); }
public void OnOuterListenerOpen(ChannelDemuxerFilter filter, IChannelListener listener, TimeSpan timeout) { TimeoutHelper helper = new TimeoutHelper(timeout); this.openSemaphore.Enter(helper.RemainingTime()); try { if (this.ShouldOpenInnerListener(filter, listener)) { try { this.innerListener.Open(helper.RemainingTime()); this.innerChannel = this.innerListener.AcceptChannel(helper.RemainingTime()); this.innerChannel.Open(helper.RemainingTime()); lock (this.ThisLock) { if (this.abortOngoingOpen) { this.AbortState(); return; } } ActionItem.Schedule(DatagramChannelDemuxer <TInnerChannel, TInnerItem> .startReceivingStatic, this); return; } catch (Exception exception) { this.pendingInnerListenerOpenException = exception; throw; } } this.ThrowPendingOpenExceptionIfAny(); } finally { this.openSemaphore.Exit(); } }
public void OnOuterListenerClose(ChannelDemuxerFilter filter, TimeSpan timeout) { bool flag = false; TimeoutHelper helper = new TimeoutHelper(timeout); lock (this.ThisLock) { if (this.filterTable.ContainsKey(filter.Filter)) { this.filterTable.Remove(filter.Filter); if (--this.openCount == 0) { flag = true; } } } if (flag) { bool flag2 = false; try { if (this.innerChannel != null) { this.innerChannel.Close(helper.RemainingTime()); } this.innerListener.Close(helper.RemainingTime()); flag2 = true; } finally { if (!flag2) { this.AbortState(); } } } }
protected override LayeredChannelListener <TChannel> CreateListener <TChannel>(ChannelDemuxerFilter filter) where TChannel : class, IChannel { SingletonChannelListener <IReplyChannel, ReplyChannel, RequestContext> listener2; if (typeof(TChannel) == typeof(IInputChannel)) { SingletonChannelListener <IInputChannel, InputChannel, Message> listener; return((LayeredChannelListener <TChannel>) new SingletonChannelListener <IInputChannel, InputChannel, Message>(filter, this) { Acceptor = new InputChannelAcceptor(listener) }); } if (typeof(TChannel) != typeof(IReplyChannel)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); } return((LayeredChannelListener <TChannel>) new SingletonChannelListener <IReplyChannel, ReplyChannel, RequestContext>(filter, this) { Acceptor = new ReplyChannelAcceptor(listener2) }); }
public InputQueueChannelListener(ChannelDemuxerFilter filter, IChannelDemuxer channelDemuxer) : base(true) { this.filter = filter; this.channelDemuxer = channelDemuxer; base.Acceptor = new InputQueueChannelAcceptor <TChannel>(this); }
public SingletonChannelListener(ChannelDemuxerFilter filter, IChannelDemuxer channelDemuxer) : base(true) { this.filter = filter; this.channelDemuxer = channelDemuxer; }
protected abstract LayeredChannelListener <TChannel> CreateListener <TChannel>(ChannelDemuxerFilter filter) where TChannel : class, IChannel;
public IChannelListener <TChannel> BuildChannelListener <TChannel>(BindingContext context, ChannelDemuxerFilter filter) where TChannel : class, IChannel { return(this.GetTypedDemuxer(typeof(TChannel), context).BuildChannelListener <TChannel>(filter)); }
public abstract IChannelListener <TChannel> BuildChannelListener <TChannel>(ChannelDemuxerFilter filter) where TChannel : class, IChannel;
public IAsyncResult OnBeginOuterListenerOpen(ChannelDemuxerFilter filter, IChannelListener listener, TimeSpan timeout, AsyncCallback callback, object state) { return(new OpenAsyncResult <TInnerChannel, TInnerItem>((DatagramChannelDemuxer <TInnerChannel, TInnerItem>) this, filter, listener, timeout, callback, state)); }
protected override LayeredChannelListener <IInputChannel> CreateListener <IInputChannel>(ChannelDemuxerFilter filter) where IInputChannel : class, IChannel { SingletonChannelListener <IInputChannel, InputChannel, Message> listener; return(new SingletonChannelListener <IInputChannel, InputChannel, Message>(filter, this) { Acceptor = (IChannelAcceptor <IInputChannel>) new InputChannelAcceptor(listener) }); }