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);
         }
     }
 }
 protected ChannelReliableSession(ChannelBase channel, IReliableFactorySettings settings, IReliableChannelBinder binder, System.ServiceModel.Channels.FaultHelper faultHelper)
 {
     this.channel         = channel;
     this.settings        = settings;
     this.binder          = binder;
     this.faultHelper     = faultHelper;
     this.inactivityTimer = new InterruptibleTimer(this.settings.InactivityTimeout, new WaitCallback(this.OnInactivityElapsed), null);
     this.initiationTime  = ReliableMessagingConstants.UnknownInitiationTime;
 }
 private void OnBinderFaulted(IReliableChannelBinder sender, Exception exception)
 {
     this.binder.Abort();
     if (((base.State == CommunicationState.Opening) || (base.State == CommunicationState.Opened)) || (base.State == CommunicationState.Closing))
     {
         exception = new CommunicationException(System.ServiceModel.SR.GetString("EarlySecurityFaulted"), exception);
         this.session.OnLocalFault(exception, (Message)null, null);
     }
 }
 protected ChannelReliableSession(ChannelBase channel, IReliableFactorySettings settings, IReliableChannelBinder binder, FaultHelper faultHelper)
 {
     this.channel = channel;
     this.settings = settings;
     this.binder = binder;
     this.faultHelper = faultHelper;
     this.inactivityTimer = new InterruptibleTimer(this.settings.InactivityTimeout, new WaitCallback(this.OnInactivityElapsed), null);
     this.initiationTime = ReliableMessagingConstants.UnknownInitiationTime;
 }
 protected ChannelReliableSession(ChannelBase channel, IReliableFactorySettings settings, IReliableChannelBinder binder, FaultHelper faultHelper)
 {
     Channel          = channel;
     Settings         = settings;
     _binder          = binder;
     FaultHelper      = faultHelper;
     _inactivityTimer = new InterruptibleTimer(Settings.InactivityTimeout, new WaitCallback(OnInactivityElapsed), null);
     InitiationTime   = ReliableMessagingConstants.UnknownInitiationTime;
 }
 private void AbortBinder(IReliableChannelBinder binder)
 {
     try
     {
         binder.Abort();
     }
     finally
     {
         this.RemoveBinder(binder);
     }
 }
        public ReliableChannelCloseAsyncResult(OperationWithTimeoutBeginCallback[] beginCallbacks, OperationEndCallback[] endCallbacks, IReliableChannelBinder binder, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
        {
            this.binder        = binder;
            this.timeoutHelper = new TimeoutHelper(timeout);
            IAsyncResult result = OperationWithTimeoutComposer.BeginComposeAsyncOperations(this.timeoutHelper.RemainingTime(), beginCallbacks, endCallbacks, onComposeAsyncOperationsComplete, this);

            if (result.CompletedSynchronously && this.CompleteComposeAsyncOperations(result))
            {
                base.Complete(true);
            }
        }
 private void OnBinderException(IReliableChannelBinder sender, Exception exception)
 {
     if (exception is QuotaExceededException)
     {
         this.session.OnLocalFault(exception, SequenceTerminatedFault.CreateQuotaExceededFault(this.session.OutputID), null);
     }
     else
     {
         base.EnqueueAndDispatch(exception, null, false);
     }
 }
 private void CompleteBinderClose(IReliableChannelBinder binder, IAsyncResult result)
 {
     try
     {
         binder.EndClose(result);
     }
     finally
     {
         this.RemoveBinder(binder);
     }
 }
        void OnBinderFaulted(IReliableChannelBinder sender, Exception exception)
        {
            this.binder.Abort();

            if (this.State == CommunicationState.Opening ||
                this.State == CommunicationState.Opened ||
                this.State == CommunicationState.Closing)
            {
                exception = new CommunicationException(SR.GetString(SR.EarlySecurityFaulted), exception);
                this.session.OnLocalFault(exception, (Message)null, null);
            }
        }
        private void OnBinderFaulted(IReliableChannelBinder sender, Exception exception)
        {
            _binder.Abort();

            if (State == CommunicationState.Opening ||
                State == CommunicationState.Opened ||
                State == CommunicationState.Closing)
            {
                exception = new CommunicationException(SR.EarlySecurityFaulted, exception);
                _session.OnLocalFault(exception, (Message)null, null);
            }
        }
        private void AsyncCloseBinder(IReliableChannelBinder binder)
        {
            if (this.onBinderCloseComplete == null)
            {
                this.onBinderCloseComplete = Fx.ThunkCallback(new AsyncCallback(this.OnBinderCloseComplete));
            }
            IAsyncResult result = binder.BeginClose(this.defaultCloseTimeout, this.onBinderCloseComplete, binder);

            if (result.CompletedSynchronously)
            {
                this.CompleteBinderClose(binder, result);
            }
        }
 private void OnBinderException(IReliableChannelBinder sender, Exception exception)
 {
     if (exception is QuotaExceededException)
     {
         if (((base.State == CommunicationState.Opening) || (base.State == CommunicationState.Opened)) || (base.State == CommunicationState.Closing))
         {
             this.session.OnLocalFault(exception, SequenceTerminatedFault.CreateQuotaExceededFault(this.session.OutputID), null);
         }
     }
     else
     {
         base.AddPendingException(exception);
     }
 }
 public override void SendFaultAsync(IReliableChannelBinder binder, RequestContext requestContext, Message faultMessage)
 {
     try
     {
         bool   flag  = true;
         TState state = this.GetState(requestContext, faultMessage);
         lock (base.ThisLock)
         {
             if (this.faultList != null)
             {
                 flag = false;
                 this.faultList.Add(binder, state);
                 if (this.onSendFaultComplete == null)
                 {
                     this.onSendFaultComplete = Fx.ThunkCallback(new AsyncCallback(this.OnSendFaultComplete));
                 }
             }
         }
         if (flag)
         {
             this.AbortState(state, false);
             binder.Abort();
         }
         else if (Thread.CurrentThread.IsThreadPoolThread)
         {
             this.SendFault(binder, state);
         }
         else
         {
             if (this.sendFaultCallback == null)
             {
                 this.sendFaultCallback = new Action <object>(this.SendFaultCallback);
             }
             ActionItem.Schedule(this.sendFaultCallback, binder);
         }
     }
     catch (Exception exception)
     {
         if (Fx.IsFatal(exception))
         {
             throw;
         }
         binder.HandleException(exception);
     }
 }
 private void OnBinderCloseComplete(IAsyncResult result)
 {
     if (!result.CompletedSynchronously)
     {
         IReliableChannelBinder asyncState = (IReliableChannelBinder)result.AsyncState;
         try
         {
             this.CompleteBinderClose(asyncState, result);
         }
         catch (Exception exception)
         {
             if (Fx.IsFatal(exception))
             {
                 throw;
             }
             asyncState.HandleException(exception);
         }
     }
 }
        private void CompleteSendFault(IReliableChannelBinder binder, TState state, IAsyncResult result)
        {
            bool flag = true;

            try
            {
                this.EndSendFault(binder, state, result);
                flag = false;
            }
            finally
            {
                if (flag)
                {
                    this.AbortState(state, false);
                    this.AbortBinder(binder);
                }
            }
            this.AsyncCloseBinder(binder);
        }
        protected void RemoveBinder(IReliableChannelBinder binder)
        {
            InterruptibleWaitObject closeHandle;

            lock (base.ThisLock)
            {
                if (this.faultList == null)
                {
                    return;
                }
                this.faultList.Remove(binder);
                if ((this.closeHandle == null) || (this.faultList.Count > 0))
                {
                    return;
                }
                this.faultList = null;
                closeHandle    = this.closeHandle;
            }
            closeHandle.Set();
        }
Example #18
0
        public ReliableChannelOpenAsyncResult(IReliableChannelBinder binder, ChannelReliableSession session, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
        {
            this.binder        = binder;
            this.session       = session;
            this.timeoutHelper = new TimeoutHelper(timeout);
            bool      flag  = false;
            bool      flag2 = true;
            Exception e     = null;

            try
            {
                IAsyncResult result = this.binder.BeginOpen(this.timeoutHelper.RemainingTime(), onBinderOpenComplete, this);
                flag2 = false;
                if (result.CompletedSynchronously)
                {
                    flag = this.CompleteBinderOpen(true, result);
                }
            }
            catch (Exception exception2)
            {
                if (Fx.IsFatal(exception2))
                {
                    throw;
                }
                if (flag2 || this.CloseBinder(e))
                {
                    throw;
                }
            }
            finally
            {
                if (flag2)
                {
                    this.binder.Abort();
                }
            }
            if (flag)
            {
                base.Complete(true);
            }
        }
 public ReliableChannelOpenAsyncResult(IReliableChannelBinder binder, ChannelReliableSession session, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.binder = binder;
     this.session = session;
     this.timeoutHelper = new TimeoutHelper(timeout);
     bool flag = false;
     bool flag2 = true;
     Exception e = null;
     try
     {
         IAsyncResult result = this.binder.BeginOpen(this.timeoutHelper.RemainingTime(), onBinderOpenComplete, this);
         flag2 = false;
         if (result.CompletedSynchronously)
         {
             flag = this.CompleteBinderOpen(true, result);
         }
     }
     catch (Exception exception2)
     {
         if (Fx.IsFatal(exception2))
         {
             throw;
         }
         if (flag2 || this.CloseBinder(e))
         {
             throw;
         }
     }
     finally
     {
         if (flag2)
         {
             this.binder.Abort();
         }
     }
     if (flag)
     {
         base.Complete(true);
     }
 }
        protected void SendFault(IReliableChannelBinder binder, TState state)
        {
            IAsyncResult result;
            bool         flag = true;

            try
            {
                result = this.BeginSendFault(binder, state, this.defaultSendTimeout, this.onSendFaultComplete, binder);
                flag   = false;
            }
            finally
            {
                if (flag)
                {
                    this.AbortState(state, false);
                    this.AbortBinder(binder);
                }
            }
            if (result.CompletedSynchronously)
            {
                this.CompleteSendFault(binder, state, result);
            }
        }
 public abstract void SendFaultAsync(IReliableChannelBinder binder, RequestContext requestContext, Message faultMessage);
 public abstract void SendFaultAsync(IReliableChannelBinder binder, RequestContext requestContext, Message faultMessage);
 protected abstract void EndSendFault(IReliableChannelBinder binder, TState state, IAsyncResult result);
 public ClientReliableDuplexSessionChannel(ChannelManagerBase factory, IReliableFactorySettings settings, IReliableChannelBinder binder, FaultHelper faultHelper, LateBoundChannelParameterCollection channelParameters, UniqueId inputID) : base(factory, settings, binder)
 {
     this.clientSession = new DuplexClientReliableSession(this, settings, faultHelper, inputID);
     this.clientSession.PollingCallback = new ClientReliableSession.PollingHandler(this.PollingCallback);
     base.SetSession(this.clientSession);
     this.channelParameters = channelParameters;
     channelParameters.SetChannel(this);
     ((IClientReliableChannelBinder)binder).ConnectionLost += new EventHandler(this.OnConnectionLost);
 }
 protected override IAsyncResult BeginSendFault(IReliableChannelBinder binder, Message message, TimeSpan timeout, AsyncCallback callback, object state)
 {
     return(binder.BeginSend(message, timeout, callback, state));
 }
 protected override void EndSendFault(IReliableChannelBinder binder, Message message, IAsyncResult result)
 {
     binder.EndSend(result);
     message.Close();
 }
        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);
                }
            }
        }
Example #28
0
 protected override void EndSendFault(IReliableChannelBinder binder, FaultState faultState, IAsyncResult result)
 {
     faultState.RequestContext.EndReply(result);
     faultState.FaultMessage.Close();
 }
 private void OnBinderFaulted(IReliableChannelBinder sender, Exception exception)
 {
     this.binder.Abort();
     exception = new CommunicationException(System.ServiceModel.SR.GetString("EarlySecurityFaulted"), exception);
     this.session.OnLocalFault(exception, (Message)null, null);
 }
Example #30
0
 protected override IAsyncResult BeginSendFault(IReliableChannelBinder binder, FaultState faultState, TimeSpan timeout, AsyncCallback callback, object state)
 {
     return(faultState.RequestContext.BeginReply(faultState.FaultMessage, timeout, callback, state));
 }
 public static bool ValidateWsrmRequest(ChannelReliableSession session, WsrmRequestInfo info, IReliableChannelBinder binder, RequestContext context)
 {
     if (!(info is CloseSequenceInfo) && !(info is TerminateSequenceInfo))
     {
         throw Fx.AssertAndThrow("Method is meant for CloseSequence or TerminateSequence only.");
     }
     if (info.ReplyTo.Uri != binder.RemoteAddress.Uri)
     {
         string    faultReason      = System.ServiceModel.SR.GetString("WsrmRequestIncorrectReplyToFaultString", new object[] { info.RequestName });
         string    exceptionMessage = System.ServiceModel.SR.GetString("WsrmRequestIncorrectReplyToExceptionString", new object[] { info.RequestName });
         WsrmFault fault            = SequenceTerminatedFault.CreateProtocolFault(session.InputID, faultReason, exceptionMessage);
         session.OnLocalFault(fault.CreateException(), fault, context);
         return(false);
     }
     return(true);
 }
 protected abstract IAsyncResult BeginSendFault(IReliableChannelBinder binder, TState state, TimeSpan timeout, AsyncCallback callback, object asyncState);