internal override void OnBegin(ushort remoteChannel, Begin begin)
        {
            // this sends a begin to the remote peer
            begin.RemoteChannel = remoteChannel;
            var session = new ListenerSession(this, begin);

            // this updates the local session state
            begin.RemoteChannel = session.Channel;
            base.OnBegin(remoteChannel, begin);
        }
Exemple #2
0
        internal Session(Connection connection, Begin begin)
        {
            this.connection = connection;
            this.channel = connection.AddSession(this);
            this.handleMax = begin.HandleMax;
            this.localLinks = new Link[1];
            this.remoteLinks = new Link[1];
            this.incomingList = new LinkedList();
            this.outgoingList = new LinkedList();
            this.nextOutgoingId = uint.MaxValue - 2u;
            this.outgoingWindow = begin.IncomingWindow;
            this.incomingDeliveryId = uint.MaxValue;

            begin.NextOutgoingId = this.nextOutgoingId;
            this.state = State.BeginSent;
            this.SendBegin(begin);
        }
        internal override void OnBegin(ushort remoteChannel, Begin begin)
        {
            // this sends a begin to the remote peer
            Begin local = new Begin()
            {
                RemoteChannel = remoteChannel,
                IncomingWindow = Session.defaultWindowSize,
                OutgoingWindow = begin.IncomingWindow,
                NextOutgoingId = 0,
                HandleMax = (uint)(this.listener.AMQP.MaxLinksPerSession - 1)
            };

            if (begin.HandleMax < local.HandleMax)
            {
                local.HandleMax = begin.HandleMax;
            }

            var session = new ListenerSession(this, local);

            // this updates the local session state
            begin.RemoteChannel = session.Channel;
            base.OnBegin(remoteChannel, begin);
        }
Exemple #4
0
        internal virtual void OnBegin(ushort remoteChannel, Begin begin)
        {
            lock (this.ThisLock)
            {
                if (remoteChannel > this.channelMax)
                {
                    throw new AmqpException(ErrorCode.NotAllowed,
                        Fx.Format(SRAmqp.AmqpHandleExceeded, this.channelMax + 1));
                }

                Session session = this.GetSession(this.localSessions, begin.RemoteChannel);
                session.OnBegin(remoteChannel, begin);

                int count = this.remoteSessions.Length;
                if (count - 1 < remoteChannel)
                {
                    int size = Math.Min(count * 2, this.channelMax + 1);
                    Session[] expanded = new Session[size];
                    Array.Copy(this.remoteSessions, expanded, count);
                    this.remoteSessions = expanded;
                }

                var remoteSession = this.remoteSessions[remoteChannel];
                if (remoteSession != null)
                {
                    throw new AmqpException(ErrorCode.HandleInUse,
                        Fx.Format(SRAmqp.AmqpHandleInUse, remoteChannel, remoteSession.GetType().Name));
                }

                this.remoteSessions[remoteChannel] = session;
            }
        }
Exemple #5
0
 void SendBegin(Begin begin)
 {
     this.connection.SendCommand(this.channel, begin);
 }
Exemple #6
0
        internal void OnBegin(ushort remoteChannel, Begin begin)
        {
            lock (this.ThisLock)
            {
                if (this.state == State.BeginSent)
                {
                    this.state = State.Opened;
                }
                else if (this.state == State.EndPipe)
                {
                    this.state = State.EndSent;
                }
                else
                {
                    throw new AmqpException(ErrorCode.IllegalState,
                        Fx.Format(SRAmqp.AmqpIllegalOperationState, "OnBegin", this.state));
                }

                this.outgoingWindow = begin.IncomingWindow;
            }

            if (begin.HandleMax < this.handleMax)
            {
                this.handleMax = begin.HandleMax;
            }
        }
 internal ListenerSession(ListenerConnection connection, Begin begin)
     : base(connection, begin)
 {
 }