Exemple #1
0
        protected AmqpObjectState SendEnd()
        {
            StateTransition stateTransition   = base.TransitState("S:END", StateTransition.SendClose);
            End             end               = new End();
            Exception       terminalException = base.TerminalException;

            if (terminalException != null)
            {
                end.Error = AmqpError.FromException(terminalException, true);
            }
            this.SendCommand(end);
            return(stateTransition.To);
        }
Exemple #2
0
 static StateTransition()
 {
     StateTransition[] stateTransition = new StateTransition[] { new StateTransition(AmqpObjectState.Start, AmqpObjectState.HeaderSent), new StateTransition(AmqpObjectState.HeaderReceived, AmqpObjectState.HeaderExchanged) };
     StateTransition.sendHeader = stateTransition;
     StateTransition[] stateTransitionArray = new StateTransition[] { new StateTransition(AmqpObjectState.Start, AmqpObjectState.OpenSent), new StateTransition(AmqpObjectState.OpenReceived, AmqpObjectState.Opened), new StateTransition(AmqpObjectState.HeaderSent, AmqpObjectState.OpenPipe), new StateTransition(AmqpObjectState.HeaderExchanged, AmqpObjectState.OpenSent) };
     StateTransition.sendOpen = stateTransitionArray;
     StateTransition[] stateTransition1 = new StateTransition[] { new StateTransition(AmqpObjectState.Opened, AmqpObjectState.CloseSent), new StateTransition(AmqpObjectState.CloseReceived, AmqpObjectState.End), new StateTransition(AmqpObjectState.OpenSent, AmqpObjectState.ClosePipe), new StateTransition(AmqpObjectState.OpenPipe, AmqpObjectState.OpenClosePipe), new StateTransition(AmqpObjectState.Faulted, AmqpObjectState.Faulted) };
     StateTransition.sendClose = stateTransition1;
     StateTransition[] stateTransitionArray1 = new StateTransition[] { new StateTransition(AmqpObjectState.Start, AmqpObjectState.HeaderReceived), new StateTransition(AmqpObjectState.HeaderSent, AmqpObjectState.HeaderExchanged), new StateTransition(AmqpObjectState.OpenPipe, AmqpObjectState.OpenSent), new StateTransition(AmqpObjectState.OpenClosePipe, AmqpObjectState.ClosePipe) };
     StateTransition.receiveHeader = stateTransitionArray1;
     StateTransition[] stateTransition2 = new StateTransition[] { new StateTransition(AmqpObjectState.Start, AmqpObjectState.OpenReceived), new StateTransition(AmqpObjectState.OpenSent, AmqpObjectState.Opened), new StateTransition(AmqpObjectState.HeaderReceived, AmqpObjectState.OpenReceived), new StateTransition(AmqpObjectState.HeaderExchanged, AmqpObjectState.OpenReceived), new StateTransition(AmqpObjectState.ClosePipe, AmqpObjectState.CloseSent) };
     StateTransition.receiveOpen = stateTransition2;
     StateTransition[] stateTransitionArray2 = new StateTransition[] { new StateTransition(AmqpObjectState.Opened, AmqpObjectState.CloseReceived), new StateTransition(AmqpObjectState.CloseSent, AmqpObjectState.End), new StateTransition(AmqpObjectState.OpenReceived, AmqpObjectState.CloseReceived), new StateTransition(AmqpObjectState.Faulted, AmqpObjectState.End) };
     StateTransition.receiveClose = stateTransitionArray2;
 }
Exemple #3
0
        private AmqpObjectState SendDetach()
        {
            StateTransition stateTransition = base.TransitState("S:DETACH", StateTransition.SendClose);
            Detach          detach          = new Detach()
            {
                Handle = this.LocalHandle,
                Closed = new bool?(true)
            };
            Exception terminalException = base.TerminalException;

            if (terminalException != null)
            {
                detach.Error = AmqpError.FromException(terminalException, true);
            }
            this.Session.SendCommand(detach);
            return(stateTransition.To);
        }
Exemple #4
0
        private void OnReceiveBegin(Begin begin)
        {
            StateTransition stateTransition = base.TransitState("R:BEGIN", StateTransition.ReceiveOpen);

            this.incomingChannel.OnBegin(begin);
            if (stateTransition.To == AmqpObjectState.OpenReceived)
            {
                base.Open();
                return;
            }
            Exception amqpException = null;
            Error     error         = this.Negotiate(begin);

            if (error != null)
            {
                amqpException = new AmqpException(error);
            }
            base.CompleteOpen(false, amqpException);
            if (amqpException != null)
            {
                base.SafeClose(amqpException);
            }
        }
Exemple #5
0
        protected void TransitState(string operation, StateTransition[] states, out StateTransition state)
        {
            state = null;

            lock (this.ThisLock)
            {
                foreach (StateTransition st in states)
                {
                    if (st.From == this.State)
                    {
                        this.State = st.To;
                        state      = st;
                        break;
                    }
                }
            }

            if (state == null)
            {
                throw new AmqpException(AmqpError.IllegalState, SRClient.AmqpIllegalOperationState(operation, this.State));
            }

            Utils.Trace(TraceLevel.Info, "{0}: {1} {2} -> {3}", this, operation, state.From, state.To);
        }
Exemple #6
0
        private void OnReceiveAttach(Attach attach)
        {
            StateTransition stateTransition = base.TransitState("R:ATTACH", StateTransition.ReceiveOpen);
            Error           error           = this.Negotiate(attach);

            if (error != null)
            {
                this.OnLinkOpenFailed(new AmqpException(error));
                return;
            }
            if (stateTransition.From == AmqpObjectState.OpenSent)
            {
                if (!this.IsReceiver)
                {
                    Target target = this.settings.Target as Target;
                    if (target != null && target.Dynamic())
                    {
                        target.Address = ((Target)attach.Target).Address;
                    }
                }
                else
                {
                    Source source = this.settings.Source as Source;
                    if (source != null && source.Dynamic())
                    {
                        source.Address = ((Source)attach.Source).Address;
                    }
                }
                if (attach.Properties != null)
                {
                    if (this.Settings.Properties != null)
                    {
                        this.settings.Properties.Merge(attach.Properties);
                    }
                    else
                    {
                        this.settings.Properties = attach.Properties;
                    }
                }
            }
            if (stateTransition.To != AmqpObjectState.Opened)
            {
                if (stateTransition.To == AmqpObjectState.OpenReceived)
                {
                    try
                    {
                        this.Session.LinkFactory.BeginOpenLink(this, base.DefaultOpenTimeout, new AsyncCallback(this.OnProviderLinkOpened), null);
                    }
                    catch (Exception exception1)
                    {
                        Exception exception = exception1;
                        if (Fx.IsFatal(exception))
                        {
                            throw;
                        }
                        this.OnLinkOpenFailed(exception);
                    }
                }
                return;
            }
            if (this.IsReceiver && attach.Source == null || !this.IsReceiver && attach.Target == null)
            {
                return;
            }
            if (!this.IsReceiver)
            {
                this.settings.Target = attach.Target;
            }
            else
            {
                this.deliveryCount   = attach.InitialDeliveryCount.Value;
                this.settings.Source = attach.Source;
            }
            this.settings.SettleType = attach.SettleType();
            base.CompleteOpen(false, null);
        }
Exemple #7
0
        protected void TransitState(string operation, StateTransition[] states, out StateTransition state)
        {
            state = null;

            lock (this.ThisLock)
            {
                foreach (StateTransition st in states)
                {
                    if (st.From == this.State)
                    {
                        this.State = st.To;
                        state = st;
                        break;
                    }
                }
            }

            if (state == null)
            {
                throw new AmqpException(AmqpError.IllegalState, SRClient.AmqpIllegalOperationState(operation, this.State));
            }

            Utils.Trace(TraceLevel.Info, "{0}: {1} {2} -> {3}", this, operation, state.From, state.To);
        }
Exemple #8
0
 protected void TransitState(string operation, StateTransition[] states)
 {
     StateTransition state;
     this.TransitState(operation, states, out state);
 }