Ejemplo n.º 1
0
        public override bool Equals(object obj)
        {
            ProtocolHeader otherHeader = obj as ProtocolHeader;

            if (otherHeader == null)
            {
                return(false);
            }

            return(otherHeader.protocolId == this.protocolId &&
                   otherHeader.version.Equals(this.version));
        }
Ejemplo n.º 2
0
        public override bool Equals(object obj)
        {
            ProtocolHeader protocolHeader = obj as ProtocolHeader;

            if (protocolHeader == null)
            {
                return(false);
            }
            if (protocolHeader.protocolId != this.protocolId)
            {
                return(false);
            }
            return(protocolHeader.version.Equals(this.version));
        }
Ejemplo n.º 3
0
        public AmqpConnection(TransportBase transport, ProtocolHeader protocolHeader, bool isInitiator, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) :
            base(transport, connectionSettings)
        {
            if (amqpSettings == null)
            {
                throw new ArgumentNullException("amqpSettings");
            }

            this.initialHeader = protocolHeader;
            this.isInitiator = isInitiator;
            this.amqpSettings = amqpSettings;
            this.frameDecoder = new FrameDecoder((int)this.Settings.MaxFrameSize);
            this.sessionsByLocalHandle = new HandleTable<AmqpSession>(this.Settings.ChannelMax.Value);
            this.sessionsByRemoteHandle = new HandleTable<AmqpSession>(this.Settings.ChannelMax.Value);
            this.SessionFactory = this;
        }
Ejemplo n.º 4
0
        public static ProtocolHeader Decode(ByteBuffer buffer)
        {
            if (buffer.Length < ProtocolHeader.Size)
            {
                throw AmqpEncoding.GetEncodingException("BufferSize");
            }

            uint prefix = AmqpBitConverter.ReadUInt(buffer);
            if (prefix != ProtocolHeader.AmqpPrefix)
            {
                throw AmqpEncoding.GetEncodingException("ProtocolName");
            }

            ProtocolHeader header = new ProtocolHeader();
            header.protocolId = (ProtocolId)AmqpBitConverter.ReadUByte(buffer);
            header.version = new AmqpVersion(AmqpBitConverter.ReadUByte(buffer), AmqpBitConverter.ReadUByte(buffer), AmqpBitConverter.ReadUByte(buffer));
            header.Buffer = new ArraySegment<byte>(buffer.Buffer, buffer.Offset - ProtocolHeader.Size, ProtocolHeader.Size);
            return header;
        }
Ejemplo n.º 5
0
        public static ProtocolHeader Decode(ByteBuffer buffer)
        {
            if (buffer.Length < ProtocolHeader.Size)
            {
                throw AmqpEncoding.GetEncodingException("BufferSize");
            }

            uint prefix = AmqpBitConverter.ReadUInt(buffer);

            if (prefix != ProtocolHeader.AmqpPrefix)
            {
                throw AmqpEncoding.GetEncodingException("ProtocolName");
            }

            ProtocolHeader header = new ProtocolHeader();

            header.protocolId = (ProtocolId)AmqpBitConverter.ReadUByte(buffer);
            header.version    = new AmqpVersion(AmqpBitConverter.ReadUByte(buffer), AmqpBitConverter.ReadUByte(buffer), AmqpBitConverter.ReadUByte(buffer));
            header.Buffer     = new ArraySegment <byte>(buffer.Buffer, buffer.Offset - ProtocolHeader.Size, ProtocolHeader.Size);
            return(header);
        }
Ejemplo n.º 6
0
 public AmqpConnection(TransportBase transport, ProtocolHeader protocolHeader, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) :
     this(transport, protocolHeader, true, amqpSettings, connectionSettings)
 {
 }
Ejemplo n.º 7
0
 void SendProtocolHeader(ProtocolHeader header)
 {
     this.TransitState("S:HDR", StateTransition.SendHeader);
     this.AsyncIO.Writer.WriteBuffer(header.Buffer, null, null, null);
     Utils.Trace(TraceLevel.Frame, "SEND  {0}", header);
 }
Ejemplo n.º 8
0
        protected override void OnProtocolHeader(ProtocolHeader header)
        {
            Utils.Trace(TraceLevel.Frame, "RECV  {0}", header);
            this.TransitState("R:HDR", StateTransition.ReceiveHeader);
            Exception exception = null;

            if (this.isInitiator)
            {
                if (!this.initialHeader.Equals(header))
                {
                    exception = new AmqpException(AmqpError.NotImplemented, SRClient.ProtocolVersionNotSupported(this.initialHeader.ToString(), header.ToString()));
                }
            }
            else
            {
                ProtocolHeader supportedHeader = this.amqpSettings.GetSupportedHeader(header);                
                this.SendProtocolHeader(supportedHeader);
                if (!supportedHeader.Equals(header))
                {
                    exception = new AmqpException(AmqpError.NotImplemented, SRClient.ProtocolVersionNotSupported(this.initialHeader.ToString(), header.ToString()));
                }
            }

            if (exception != null)
            {
                this.CompleteOpen(false, exception);
            }
        }
Ejemplo n.º 9
0
 AmqpConnection IConnectionFactory.CreateConnection(TransportBase transport, ProtocolHeader protocolHeader, bool isInitiator, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 10
0
 static ProtocolHeader()
 {
     ProtocolHeader.Amqp100     = new ProtocolHeader(Microsoft.ServiceBus.Messaging.Amqp.ProtocolId.Amqp, new AmqpVersion(1, 0, 0));
     ProtocolHeader.AmqpTls100  = new ProtocolHeader(Microsoft.ServiceBus.Messaging.Amqp.ProtocolId.AmqpTls, new AmqpVersion(1, 0, 0));
     ProtocolHeader.AmqpSasl100 = new ProtocolHeader(Microsoft.ServiceBus.Messaging.Amqp.ProtocolId.AmqpSasl, new AmqpVersion(1, 0, 0));
 }
Ejemplo n.º 11
0
        public AmqpConnection CreateConnection(TransportBase transport, ProtocolHeader protocolHeader, bool isInitiator, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings)
        {
            if (this.amqpSettings.RequireSecureTransport && !transport.IsSecure)
            {
                throw new AmqpException(AmqpError.NotAllowed, SR.AmqpTransportNotSecure);
            }

            AmqpConnection connection = new AmqpConnection(transport, protocolHeader, isInitiator, amqpSettings, connectionSettings);
            Utils.Trace(TraceLevel.Info, "{0}: Created {1}", this, connection);
            return connection;
        }
Ejemplo n.º 12
0
 protected abstract void OnProtocolHeader(ProtocolHeader header);
Ejemplo n.º 13
0
 protected override void OnProtocolHeader(ProtocolHeader header)
 {
     if (!this.parent.encoding)
     {
         this.CompleteOpen(false, null);
     }
     else
     {
         this.State = AmqpObjectState.HeaderExchanged;
     }
 }
Ejemplo n.º 14
0
            void WriteReplyHeader(ProtocolHeader header, bool fail)
            {
                Utils.Trace(TraceLevel.Verbose, "{0}: Write reply protocol header {1}", this, header);
                Utils.Trace(TraceLevel.Frame, "SEND  {0}", header);
                this.args.SetBuffer(header.Buffer);
                this.args.CompletedCallback = fail ? null : this.writeCompleteCallback;
                this.bufferWriter.WriteBuffer(this.args);

                if (fail)
                {
                    this.args.Exception = new NotSupportedException(header.ToString());
                    this.parent.OnHandleTransportComplete(this.args);
                }
            }