Esempio n. 1
0
 public static bool CanReceiveFrames(this SessionStateEnum state)
 {
     return(state == SessionStateEnum.BEGIN_RCVD ||
            state == SessionStateEnum.MAPPED ||
            state == SessionStateEnum.END_SENT ||
            state == SessionStateEnum.DISCARDING);
 }
Esempio n. 2
0
 private void Init()
 {
     SessionState = SessionStateEnum.Running;
     CreateModules();
     InitModules();
     Inited = true;
 }
Esempio n. 3
0
 protected override void UnloadData()
 {
     SessionState = SessionStateEnum.Unloading;
     UnloadModules();
 }
Esempio n. 4
0
 public override void LoadData()
 {
     SessionState = SessionStateEnum.Loading;
     LoadModules();
 }
Esempio n. 5
0
 public static bool CanSendFrames(this SessionStateEnum state)
 {
     return(state == SessionStateEnum.BEGIN_SENT ||
            state == SessionStateEnum.MAPPED ||
            state == SessionStateEnum.END_RCVD);
 }
Esempio n. 6
0
 private void UnmapSession()
 {
     // TODO: detach links
     State = SessionStateEnum.UNMAPPED;
     Connection.NotifySessionUnmapped(this);
 }
Esempio n. 7
0
        private void HandleEndFrame(End end)
        {
            if (State != SessionStateEnum.MAPPED && State != SessionStateEnum.END_SENT && State != SessionStateEnum.DISCARDING)
                throw new AmqpException(ErrorCode.IllegalState, $"Received End frame but session state is {State.ToString()}.");

            if (end.Error != null)
            {
                trace.Debug("Ending Session {0} Due to Error From Remote Session: '{1}'", ChannelNumber, end.Error);
            }

            // TODO detach links

            if (State == SessionStateEnum.MAPPED)
                State = SessionStateEnum.END_RCVD;

            EndSession(error: null); // don't pass the error: that's only if the error occured in our session
        }
Esempio n. 8
0
        private void HandleBeginFrame(Begin begin)
        {
            if (State != SessionStateEnum.UNMAPPED && State != SessionStateEnum.BEGIN_SENT)
                throw new AmqpException(ErrorCode.IllegalState, $"Received Begin frame but session state is {State.ToString()}.");

            nextOutgoingId = InitialOutgoingId; // our next id
            incomingWindow = DefaultWindowSize; // our incoming window

            nextIncomingId = begin.NextOutgoingId; // their next id
            outgoingWindow = remoteIncomingWindow = begin.IncomingWindow; // their incoming window (and now our outgoing window)
            remoteOutgoingWindow = begin.OutgoingWindow; // their advertized outgoing window

            sessionMaxHandle = Math.Min(DefaultMaxHandle, begin.HandleMax ?? DefaultMaxHandle);

            if (State == SessionStateEnum.BEGIN_SENT)
            {
                if (begin.RemoteChannel == null)
                {
                    throw new AmqpException(ErrorCode.InvalidField, "Expecting to receive RemoteChannel");
                }
                RemoteChannelNumber = begin.RemoteChannel.Value;
                State = SessionStateEnum.MAPPED;
                return;
            }
            else
            {
                State = SessionStateEnum.BEGIN_RCVD;

                // reset values and send back the frame
                begin.RemoteChannel = RemoteChannelNumber;
                begin.NextOutgoingId = nextOutgoingId;
                begin.IncomingWindow = incomingWindow;
                begin.OutgoingWindow = outgoingWindow;
                begin.HandleMax = sessionMaxHandle;
                Connection.SendFrame(begin, ChannelNumber);

                State = SessionStateEnum.MAPPED;
                return;
            }
        }
Esempio n. 9
0
        public void EndSession(Error error)
        {
            if (State == SessionStateEnum.MAPPED
                || State == SessionStateEnum.END_RCVD
                || State == SessionStateEnum.DISCARDING)
            {
                Connection.SendFrame(new End()
                {
                    Error = error,
                }, ChannelNumber);

                if (State == SessionStateEnum.MAPPED)
                {
                    State = SessionStateEnum.END_SENT;
                    if (error != null)
                        State = SessionStateEnum.DISCARDING;
                }
                else if (State == SessionStateEnum.END_RCVD || State == SessionStateEnum.DISCARDING)
                {
                    UnmapSession();
                }

                return;
            }

            if (error != null)
            {
                // no session to end, so close the connection
                Connection.CloseConnection(error);
                return;
            }
        }