internal bool OnFrame()

in src/Sasl/SaslProfile.cs [132:187]


        internal bool OnFrame(string hostname, ITransport transport, ByteBuffer buffer, out SaslCode code)
        {
            ushort channel;
            DescribedList command;
            Frame.Decode(buffer, out channel, out command);
            Trace.WriteLine(TraceLevel.Frame, "RECV {0}", command);

            bool shouldContinue = true;
            if (command.Descriptor.Code == Codec.SaslOutcome.Code)
            {
                code = ((SaslOutcome)command).Code;
                shouldContinue = false;
            }
            else if (command.Descriptor.Code == Codec.SaslMechanisms.Code)
            {
                code = SaslCode.Ok;
                SaslMechanisms mechanisms = (SaslMechanisms)command;
                Symbol matched = null;
                foreach (var m in mechanisms.SaslServerMechanisms)
                {
                    if (this.Match(m))
                    {
                        this.Mechanism = m;
                        matched = m;
                        break;
                    }
                }

                if (matched == null)
                {
                    throw new AmqpException(ErrorCode.NotImplemented, mechanisms.ToString());
                }

                DescribedList init = this.GetStartCommand(hostname);
                if (init != null)
                {
                    this.SendCommand(transport, init);
                }
            }
            else
            {
                code = SaslCode.Ok;
                DescribedList response = this.OnCommand(command);
                if (response != null)
                {
                    this.SendCommand(transport, response);
                    if (response.Descriptor.Code == Codec.SaslOutcome.Code)
                    {
                        code = ((SaslOutcome)response).Code;
                        shouldContinue = false;
                    }
                }
            }

            return shouldContinue;
        }