Beispiel #1
0
        protected override void OnProtocolHeader(ProtocolHeader header)
        {
            base.TransitState("R:HDR", StateTransition.ReceiveHeader);
            Exception amqpException = null;

            if (!this.isInitiator)
            {
                ProtocolHeader supportedHeader = this.amqpSettings.GetSupportedHeader(header);
                this.SendProtocolHeader(supportedHeader);
                if (!supportedHeader.Equals(header))
                {
                    amqpException = new AmqpException(AmqpError.NotImplemented, SRAmqp.AmqpProtocolVersionNotSupported(this.initialHeader.ToString(), header.ToString()));
                }
            }
            else if (!this.initialHeader.Equals(header))
            {
                amqpException = new AmqpException(AmqpError.NotImplemented, SRAmqp.AmqpProtocolVersionNotSupported(this.initialHeader.ToString(), header.ToString()));
            }
            if (amqpException != null)
            {
                base.CompleteOpen(false, amqpException);
            }
        }
Beispiel #2
0
 private void OnReadHeaderComplete(TransportAsyncCallbackArgs args)
 {
     if (args.Exception != null)
     {
         MessagingClientEtwProvider.TraceClient <AmqpTransportInitiator, Exception>((AmqpTransportInitiator source, Exception ex) => MessagingClientEtwProvider.Provider.EventWriteAmqpLogError(source, "ReadHeader", ex.Message), this, args.Exception);
         this.Complete(args);
         return;
     }
     try
     {
         ProtocolHeader protocolHeader = new ProtocolHeader();
         protocolHeader.Decode(new ByteBuffer(args.Buffer, args.Offset, args.Count));
         if (!protocolHeader.Equals(this.sentHeader))
         {
             throw new AmqpException(AmqpError.NotImplemented, SRAmqp.AmqpProtocolVersionNotSupported(this.sentHeader, protocolHeader));
         }
         TransportBase transportBase = this.settings.TransportProviders[this.providerIndex].CreateTransport(args.Transport, true);
         MessagingClientEtwProvider.TraceClient <AmqpTransportInitiator, TransportBase, TransportBase>((AmqpTransportInitiator source, TransportBase from, TransportBase to) => MessagingClientEtwProvider.Provider.EventWriteAmqpUpgradeTransport(source, from, to), this, args.Transport, transportBase);
         args.Transport = transportBase;
         IAsyncResult asyncResult = args.Transport.BeginOpen(this.timeoutHelper.RemainingTime(), new AsyncCallback(this.OnTransportOpenCompete), args);
         if (asyncResult.CompletedSynchronously)
         {
             this.HandleTransportOpened(asyncResult);
         }
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         if (Fx.IsFatal(exception))
         {
             throw;
         }
         MessagingClientEtwProvider.TraceClient <AmqpTransportInitiator, Exception>((AmqpTransportInitiator source, Exception ex) => MessagingClientEtwProvider.Provider.EventWriteAmqpLogError(source, "OnProtocolHeader", ex.Message), this, exception);
         args.Exception = exception;
         this.Complete(args);
     }
 }