Exemple #1
0
        public void Open(bool insist)
        {
            BlockingCell connectionStartCell = new BlockingCell();

            m_model0.m_connectionStartCell = connectionStartCell;
            m_frameHandler.Timeout         = HandshakeTimeout;
            m_frameHandler.SendHeader();

            ConnectionStartDetails connectionStart = (ConnectionStartDetails)
                                                     connectionStartCell.Value;

            AmqpVersion serverVersion = new AmqpVersion(connectionStart.m_versionMajor,
                                                        connectionStart.m_versionMinor);

            if (!serverVersion.Equals(Protocol.Version))
            {
                TerminateMainloop();
                FinishClose();
                throw new ProtocolVersionMismatchException(Protocol.MajorVersion,
                                                           Protocol.MinorVersion,
                                                           serverVersion.Major,
                                                           serverVersion.Minor);
            }

            // FIXME: check that PLAIN is supported.
            // FIXME: parse out locales properly!
            ConnectionTuneDetails connectionTune =
                m_model0.ConnectionStartOk(BuildClientPropertiesTable(),
                                           "PLAIN",
                                           Encoding.UTF8.GetBytes("\0" + m_parameters.UserName +
                                                                  "\0" + m_parameters.Password),
                                           "en_US");

            ushort channelMax = (ushort)NegotiatedMaxValue(m_parameters.RequestedChannelMax,
                                                           connectionTune.m_channelMax);

            ChannelMax = channelMax;

            uint frameMax = NegotiatedMaxValue(m_parameters.RequestedFrameMax,
                                               connectionTune.m_frameMax);

            FrameMax = frameMax;

            ushort heartbeat = (ushort)NegotiatedMaxValue(m_parameters.RequestedHeartbeat,
                                                          connectionTune.m_heartbeat);

            Heartbeat = heartbeat;

            m_model0.ConnectionTuneOk(channelMax,
                                      frameMax,
                                      heartbeat);

            string knownHosts = m_model0.ConnectionOpen(m_parameters.VirtualHost,
                                                        "", // FIXME: make configurable?
                                                        insist);

            KnownHosts = AmqpTcpEndpoint.ParseMultiple(Protocol, knownHosts);
        }
Exemple #2
0
        public void HandleConnectionStart(byte versionMajor,
                                          byte versionMinor,
                                          IDictionary serverProperties,
                                          byte[] mechanisms,
                                          byte[] locales)
        {
            if (m_connectionStartCell == null)
            {
                ShutdownEventArgs reason =
                    new ShutdownEventArgs(ShutdownInitiator.Library,
                                          CommonFraming.Constants.CommandInvalid,
                                          "Unexpected Connection.Start");
                ((ConnectionBase)m_session.Connection).Close(reason);
            }
            ConnectionStartDetails details = new ConnectionStartDetails();

            details.m_versionMajor      = versionMajor;
            details.m_versionMinor      = versionMinor;
            details.m_serverProperties  = serverProperties;
            details.m_mechanisms        = mechanisms;
            details.m_locales           = locales;
            m_connectionStartCell.Value = details;
            m_connectionStartCell       = null;
        }
 public void HandleConnectionStart(byte versionMajor,
                                   byte versionMinor,
                                   IDictionary<string, object> serverProperties,
                                   byte[] mechanisms,
                                   byte[] locales)
 {
     if (m_connectionStartCell == null)
     {
         ShutdownEventArgs reason =
             new ShutdownEventArgs(ShutdownInitiator.Library,
                                   CommonFraming.Constants.CommandInvalid,
                                   "Unexpected Connection.Start");
         ((ConnectionBase)m_session.Connection).Close(reason);
     }
     ConnectionStartDetails details = new ConnectionStartDetails();
     details.m_versionMajor = versionMajor;
     details.m_versionMinor = versionMinor;
     details.m_serverProperties = serverProperties;
     details.m_mechanisms = mechanisms;
     details.m_locales = locales;
     m_connectionStartCell.Value = details;
     m_connectionStartCell = null;
 }
Exemple #4
0
        public void Open(bool insist)
        {
            BlockingCell connectionStartCell = new BlockingCell();

            m_model0.m_connectionStartCell = connectionStartCell;
            m_frameHandler.Timeout         = HandshakeTimeout;
            m_frameHandler.SendHeader();

            ConnectionStartDetails connectionStart = (ConnectionStartDetails)
                                                     connectionStartCell.Value;

            ServerProperties = connectionStart.m_serverProperties;

            AmqpVersion serverVersion = new AmqpVersion(connectionStart.m_versionMajor,
                                                        connectionStart.m_versionMinor);

            if (!serverVersion.Equals(Protocol.Version))
            {
                TerminateMainloop();
                FinishClose();
                throw new ProtocolVersionMismatchException(Protocol.MajorVersion,
                                                           Protocol.MinorVersion,
                                                           serverVersion.Major,
                                                           serverVersion.Minor);
            }

            m_clientProperties = new Hashtable(m_factory.ClientProperties);

            // FIXME: check that PLAIN is supported.
            // FIXME: parse out locales properly!
            ConnectionTuneDetails connectionTune = default(ConnectionTuneDetails);

            try
            {
                connectionTune =
                    m_model0.ConnectionStartOk(m_clientProperties,
                                               "PLAIN",
                                               Encoding.UTF8.GetBytes(
                                                   "\0" + m_factory.UserName +
                                                   "\0" + m_factory.Password),
                                               "en_US");
            }
            catch (OperationInterruptedException e)
            {
                throw new PossibleAuthenticationFailureException(
                          "Possibly caused by authentication failure", e);
            }

            ushort channelMax = (ushort)NegotiatedMaxValue(m_factory.RequestedChannelMax,
                                                           connectionTune.m_channelMax);

            m_sessionManager = new SessionManager(this, channelMax);

            uint frameMax = NegotiatedMaxValue(m_factory.RequestedFrameMax,
                                               connectionTune.m_frameMax);

            FrameMax = frameMax;

            ushort heartbeat = (ushort)NegotiatedMaxValue(m_factory.RequestedHeartbeat,
                                                          connectionTune.m_heartbeat);

            Heartbeat = heartbeat;

            m_model0.ConnectionTuneOk(channelMax,
                                      frameMax,
                                      heartbeat);

            string knownHosts = m_model0.ConnectionOpen(m_factory.VirtualHost,
                                                        "", // FIXME: make configurable?
                                                        insist);

            KnownHosts = AmqpTcpEndpoint.ParseMultiple(Protocol, knownHosts);
        }