public ServerReliableDuplexSessionChannel(ReliableChannelListenerBase <IDuplexSessionChannel> listener, IReliableChannelBinder binder, FaultHelper faultHelper, UniqueId inputID, UniqueId outputID) : base(listener, listener, binder)
        {
            this.listener = listener;
            DuplexServerReliableSession session = new DuplexServerReliableSession(this, listener, faultHelper, inputID, outputID);

            base.SetSession(session);
            session.Open(TimeSpan.Zero);
            base.SetConnections();
            if (PerformanceCounters.PerformanceCountersEnabled)
            {
                this.perfCounterId = this.listener.Uri.ToString().ToUpperInvariant();
            }
            if (binder.HasSession)
            {
                try
                {
                    base.StartReceiving(false);
                }
                catch (Exception exception)
                {
                    if (Fx.IsFatal(exception))
                    {
                        throw;
                    }
                    base.ReliableSession.OnUnknownException(exception);
                }
            }
        }
            public CloseAsyncResult(ReliableChannelListenerBase <TChannel> parent, OperationWithTimeoutBeginCallback baseBeginClose, OperationEndCallback baseEndClose, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
            {
                this.parent         = parent;
                this.baseBeginClose = baseBeginClose;
                this.baseEndClose   = baseEndClose;
                bool flag = false;

                if (this.parent.ShouldCloseOnChannelListenerClose())
                {
                    this.timeoutHelper = new TimeoutHelper(timeout);
                    IAsyncResult result = this.parent.BeginCloseInnerListener(this.timeoutHelper.RemainingTime(), ReliableChannelListenerBase <TChannel> .CloseAsyncResult.onInnerChannelListenerCloseComplete, this);
                    if (result.CompletedSynchronously)
                    {
                        flag = this.CompleteInnerChannelListenerClose(result);
                    }
                }
                else
                {
                    flag = this.CloseBaseChannelListener(timeout);
                }
                if (flag)
                {
                    base.Complete(true);
                }
            }
 public ReliableInputSessionChannelOverReply(ReliableChannelListenerBase <IInputSessionChannel> listener, IServerReliableChannelBinder binder, FaultHelper faultHelper, UniqueId inputID) : base(listener, binder, faultHelper, inputID)
 {
     if (binder.HasSession)
     {
         try
         {
             base.StartReceiving(false);
         }
         catch (Exception exception)
         {
             if (Fx.IsFatal(exception))
             {
                 throw;
             }
             base.ReliableSession.OnUnknownException(exception);
         }
     }
 }
 public OnReliableChannelCloseAsyncResult(ReliableChannelListenerBase <TChannel> channelListener, UniqueId inputId, UniqueId outputId, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     if (!channelListener.ShouldCloseOnReliableChannelClose(inputId, outputId))
     {
         base.Complete(true);
     }
     else
     {
         this.channelListener = channelListener;
         this.inputId         = inputId;
         this.outputId        = outputId;
         IAsyncResult result = this.channelListener.BeginCloseInnerListener(timeout, ReliableChannelListenerBase <TChannel> .OnReliableChannelCloseAsyncResult.onInnerChannelListenerCloseComplete, this);
         if (result.CompletedSynchronously)
         {
             this.CompleteInnerChannelListenerClose(result);
             base.Complete(true);
         }
     }
 }
예제 #5
0
 public ReliableInputSessionChannelOverDuplex(ReliableChannelListenerBase <IInputSessionChannel> listener, IServerReliableChannelBinder binder, FaultHelper faultHelper, UniqueId inputID) : base(listener, binder, faultHelper, inputID)
 {
     this.guard = new Guard(0x7fffffff);
     this.acknowledgementInterval          = listener.AcknowledgementInterval;
     this.acknowledgementTimer             = new IOThreadTimer(new Action <object>(this.OnAcknowledgementTimeoutElapsed), null, true);
     base.DeliveryStrategy.DequeueCallback = new Action(this.OnDeliveryStrategyItemDequeued);
     if (binder.HasSession)
     {
         try
         {
             base.StartReceiving(false);
         }
         catch (Exception exception)
         {
             if (Fx.IsFatal(exception))
             {
                 throw;
             }
             base.ReliableSession.OnUnknownException(exception);
         }
     }
 }
 protected ReliableInputSessionChannel(ReliableChannelListenerBase <IInputSessionChannel> listener, IServerReliableChannelBinder binder, FaultHelper faultHelper, UniqueId inputID) : base(listener, binder.LocalAddress)
 {
     this.binder     = binder;
     this.listener   = listener;
     this.connection = new ReliableInputConnection();
     this.connection.ReliableMessagingVersion = listener.ReliableMessagingVersion;
     this.session = new ServerReliableSession(this, listener, binder, faultHelper, inputID, null);
     this.session.UnblockChannelCloseCallback = new ChannelReliableSession.UnblockChannelCloseHandler(this.UnblockClose);
     if (listener.Ordered)
     {
         this.deliveryStrategy = new OrderedDeliveryStrategy <Message>(this, listener.MaxTransferWindowSize, false);
     }
     else
     {
         this.deliveryStrategy = new UnorderedDeliveryStrategy <Message>(this, listener.MaxTransferWindowSize);
     }
     this.binder.Faulted     += new BinderExceptionHandler(this.OnBinderFaulted);
     this.binder.OnException += new BinderExceptionHandler(this.OnBinderException);
     this.session.Open(TimeSpan.Zero);
     if (PerformanceCounters.PerformanceCountersEnabled)
     {
         this.perfCounterId = this.listener.Uri.ToString().ToUpperInvariant();
     }
 }
예제 #7
0
        public override IChannelListener <TChannel> BuildChannelListener <TChannel>(BindingContext context) where TChannel : class, IChannel
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }
            this.VerifyTransportMode(context);
            this.SetSecuritySettings(context);
            IMessageFilterTable <EndpointAddress> table = context.BindingParameters.Find <IMessageFilterTable <EndpointAddress> >();

            InternalDuplexBindingElement.AddDuplexListenerSupport(context, ref this.internalDuplexBindingElement);
            if (typeof(TChannel) == typeof(IInputSessionChannel))
            {
                ReliableChannelListenerBase <IInputSessionChannel> base2 = null;
                if (context.CanBuildInnerChannelListener <IReplySessionChannel>())
                {
                    base2 = new ReliableInputListenerOverReplySession(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IReplyChannel>())
                {
                    base2 = new ReliableInputListenerOverReply(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IDuplexSessionChannel>())
                {
                    base2 = new ReliableInputListenerOverDuplexSession(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IDuplexChannel>())
                {
                    base2 = new ReliableInputListenerOverDuplex(this, context);
                }
                if (base2 != null)
                {
                    base2.LocalAddresses = table;
                    return((IChannelListener <TChannel>)base2);
                }
            }
            else if (typeof(TChannel) == typeof(IDuplexSessionChannel))
            {
                ReliableChannelListenerBase <IDuplexSessionChannel> base3 = null;
                if (context.CanBuildInnerChannelListener <IDuplexSessionChannel>())
                {
                    base3 = new ReliableDuplexListenerOverDuplexSession(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IDuplexChannel>())
                {
                    base3 = new ReliableDuplexListenerOverDuplex(this, context);
                }
                if (base3 != null)
                {
                    base3.LocalAddresses = table;
                    return((IChannelListener <TChannel>)base3);
                }
            }
            else if (typeof(TChannel) == typeof(IReplySessionChannel))
            {
                ReliableChannelListenerBase <IReplySessionChannel> base4 = null;
                if (context.CanBuildInnerChannelListener <IReplySessionChannel>())
                {
                    base4 = new ReliableReplyListenerOverReplySession(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IReplyChannel>())
                {
                    base4 = new ReliableReplyListenerOverReply(this, context);
                }
                if (base4 != null)
                {
                    base4.LocalAddresses = table;
                    return((IChannelListener <TChannel>)base4);
                }
            }
            throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("TChannel", System.ServiceModel.SR.GetString("ChannelTypeNotSupported", new object[] { typeof(TChannel) }));
        }
        public static bool ValidateCreateSequence <TChannel>(WsrmMessageInfo info, ReliableChannelListenerBase <TChannel> listener, IChannel channel, out EndpointAddress acksTo) where TChannel : class, IChannel
        {
            acksTo = null;
            string reason = null;

            if (info.CreateSequenceInfo.OfferIdentifier == null)
            {
                if (typeof(TChannel) == typeof(IDuplexSessionChannel))
                {
                    reason = System.ServiceModel.SR.GetString("CSRefusedDuplexNoOffer", new object[] { listener.Uri });
                }
                else if (typeof(TChannel) == typeof(IReplySessionChannel))
                {
                    reason = System.ServiceModel.SR.GetString("CSRefusedReplyNoOffer", new object[] { listener.Uri });
                }
            }
            else if ((listener.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005) && (typeof(TChannel) == typeof(IInputSessionChannel)))
            {
                reason = System.ServiceModel.SR.GetString("CSRefusedInputOffer", new object[] { listener.Uri });
            }
            if (reason != null)
            {
                info.FaultReply     = CreateCSRefusedProtocolFault(listener.MessageVersion, listener.ReliableMessagingVersion, reason);
                info.FaultException = new ProtocolException(System.ServiceModel.SR.GetString("ConflictingOffer"));
                return(false);
            }
            if (listener.LocalAddresses != null)
            {
                Collection <EndpointAddress> results = new Collection <EndpointAddress>();
                try
                {
                    listener.LocalAddresses.GetMatchingValues(info.Message, results);
                }
                catch (CommunicationException exception)
                {
                    Message        message;
                    FaultConverter property = channel.GetProperty <FaultConverter>();
                    if (property == null)
                    {
                        property = FaultConverter.GetDefaultFaultConverter(listener.MessageVersion);
                    }
                    if (!property.TryCreateFaultMessage(exception, out message))
                    {
                        throw;
                    }
                    info.FaultReply     = message;
                    info.FaultException = new ProtocolException(System.ServiceModel.SR.GetString("MessageExceptionOccurred"), exception);
                    return(false);
                }
                if (results.Count > 0)
                {
                    EndpointAddress address = results[0];
                    acksTo = new EndpointAddress(info.CreateSequenceInfo.To, address.Identity, address.Headers);
                    return(true);
                }
                info.FaultReply     = CreateEndpointNotFoundFault(listener.MessageVersion, System.ServiceModel.SR.GetString("EndpointNotFound", new object[] { info.CreateSequenceInfo.To }));
                info.FaultException = new ProtocolException(System.ServiceModel.SR.GetString("ConflictingAddress"));
                return(false);
            }
            acksTo = new EndpointAddress(info.CreateSequenceInfo.To, new AddressHeader[0]);
            return(true);
        }
 public DuplexServerReliableSession(ServerReliableDuplexSessionChannel channel, ReliableChannelListenerBase <IDuplexSessionChannel> listener, FaultHelper faultHelper, UniqueId inputID, UniqueId outputID) : base(channel, listener, (IServerReliableChannelBinder)channel.Binder, faultHelper, inputID, outputID)
 {
     this.channel = channel;
 }
        public override IChannelListener <TChannel> BuildChannelListener <TChannel>(BindingContext context)
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            this.VerifyTransportMode(context);
            this.SetSecuritySettings(context);

#pragma warning suppress 56506 // BindingContext guarantees BindingParameters is never null.
            IMessageFilterTable <EndpointAddress> table = context.BindingParameters.Find <IMessageFilterTable <EndpointAddress> >();

            InternalDuplexBindingElement.AddDuplexListenerSupport(context, ref this.internalDuplexBindingElement);

            if (typeof(TChannel) == typeof(IInputSessionChannel))
            {
                ReliableChannelListenerBase <IInputSessionChannel> listener = null;

                if (context.CanBuildInnerChannelListener <IReplySessionChannel>())
                {
                    listener = new ReliableInputListenerOverReplySession(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IReplyChannel>())
                {
                    listener = new ReliableInputListenerOverReply(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IDuplexSessionChannel>())
                {
                    listener = new ReliableInputListenerOverDuplexSession(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IDuplexChannel>())
                {
                    listener = new ReliableInputListenerOverDuplex(this, context);
                }

                if (listener != null)
                {
                    listener.LocalAddresses = table;
                    return((IChannelListener <TChannel>)(object) listener);
                }
            }
            else if (typeof(TChannel) == typeof(IDuplexSessionChannel))
            {
                ReliableChannelListenerBase <IDuplexSessionChannel> listener = null;

                if (context.CanBuildInnerChannelListener <IDuplexSessionChannel>())
                {
                    listener = new ReliableDuplexListenerOverDuplexSession(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IDuplexChannel>())
                {
                    listener = new ReliableDuplexListenerOverDuplex(this, context);
                }

                if (listener != null)
                {
                    listener.LocalAddresses = table;
                    return((IChannelListener <TChannel>)(object) listener);
                }
            }
            else if (typeof(TChannel) == typeof(IReplySessionChannel))
            {
                ReliableChannelListenerBase <IReplySessionChannel> listener = null;

                if (context.CanBuildInnerChannelListener <IReplySessionChannel>())
                {
                    listener = new ReliableReplyListenerOverReplySession(this, context);
                }
                else if (context.CanBuildInnerChannelListener <IReplyChannel>())
                {
                    listener = new ReliableReplyListenerOverReply(this, context);
                }

                if (listener != null)
                {
                    listener.LocalAddresses = table;
                    return((IChannelListener <TChannel>)(object) listener);
                }
            }

            throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("TChannel", SR.GetString(SR.ChannelTypeNotSupported, typeof(TChannel)));
        }