示例#1
0
 public static ByteBuffer Encode(FrameType type, ushort channel, DescribedList command)
 {
     ByteBuffer buffer = new ByteBuffer(cmdBufferSize, true);
     EncodeFrame(buffer, type, channel, command);
     AmqpBitConverter.WriteInt(buffer.Buffer, 0, buffer.Length);
     return buffer;
 }
示例#2
0
 public static void Encode(ByteBuffer buffer, FrameType type, ushort channel, DescribedList command)
 {
     buffer.Append(FixedWidth.UInt);
     AmqpBitConverter.WriteUByte(buffer, DOF);
     AmqpBitConverter.WriteUByte(buffer, (byte)type);
     AmqpBitConverter.WriteUShort(buffer, channel);
     Codec.Encode(command, buffer);
     AmqpBitConverter.WriteInt(buffer.Buffer, buffer.Offset, buffer.Length);
 }
示例#3
0
            protected override DescribedList OnCommand(DescribedList command)
            {
                if (command.Descriptor.Code == Codec.SaslInit.Code)
                {
                    SaslInit init = (SaslInit)command;
                    SaslCode code = this.ValidateCredentials(init);
                    return new SaslOutcome() { Code = code };
                }

                throw new AmqpException(ErrorCode.NotAllowed, command.ToString());
            }
        protected override DescribedList OnCommand(DescribedList command)
        {
            if (command.Descriptor.Code == Codec.SaslInit.Code)
            {
                return new SaslOutcome() { Code = SaslCode.Ok };
            }
            else if (command.Descriptor.Code == Codec.SaslMechanisms.Code)
            {
                return null;
            }

            throw new AmqpException(ErrorCode.NotAllowed, command.ToString());
        }
示例#5
0
 public static void GetFrame(ByteBuffer buffer, out ushort channel, out DescribedList command)
 {
     AmqpBitConverter.ReadUInt(buffer);
     AmqpBitConverter.ReadUByte(buffer);
     AmqpBitConverter.ReadUByte(buffer);
     channel = AmqpBitConverter.ReadUShort(buffer);
     if (buffer.Length > 0)
     {
         command = (DescribedList)Codec.Decode(buffer);
     }
     else
     {
         command = null;
     }
 }
示例#6
0
 void SendCommand(ITransport transport, DescribedList command)
 {
     ByteBuffer buffer = new ByteBuffer(Frame.CmdBufferSize, true);
     Frame.Encode(buffer, FrameType.Sasl, 0, command);
     transport.Send(buffer);
     Trace.WriteLine(TraceLevel.Frame, "SEND {0}", command);
 }
示例#7
0
 /// <summary>
 /// Processes the received command and returns a response. If returns
 /// null, the SASL handshake completes.
 /// </summary>
 /// <param name="command"></param>
 /// <returns></returns>
 protected abstract DescribedList OnCommand(DescribedList command);
示例#8
0
 internal DescribedList OnCommandInternal(DescribedList command)
 {
     return this.OnCommand(command);
 }
示例#9
0
 void OnSessionCommand(ushort remoteChannel, DescribedList command, ByteBuffer buffer)
 {
     this.GetSession(this.remoteSessions, remoteChannel).OnCommand(command, buffer);
 }
示例#10
0
 internal void SendCommand(ushort channel, DescribedList command)
 {
     this.ThrowIfClosed("Send");
     ByteBuffer buffer = this.AllocateBuffer(Frame.CmdBufferSize);
     Frame.Encode(buffer, FrameType.Amqp, channel, command);
     this.transport.Send(buffer);
     Trace.WriteLine(TraceLevel.Frame, "SEND (ch={0}) {1}", channel, command);
 }
示例#11
0
 internal void SendCommand(DescribedList command)
 {
     this.connection.SendCommand(this.channel, command);
 }
示例#12
0
 internal void OnCommand(DescribedList command, ByteBuffer buffer)
 {
     Fx.Assert(this.state < State.EndReceived, "Session is ending or ended and cannot receive commands.");
     if (command.Descriptor.Code == Codec.Attach.Code)
     {
         this.OnAttach((Attach)command);
     }
     else if (command.Descriptor.Code == Codec.Detach.Code)
     {
         this.OnDetach((Detach)command);
     }
     else if (command.Descriptor.Code == Codec.Flow.Code)
     {
         this.OnFlow((Flow)command);
     }
     else if (command.Descriptor.Code == Codec.Transfer.Code)
     {
         this.OnTransfer((Transfer)command, buffer);
     }
     else if (command.Descriptor.Code == Codec.Dispose.Code)
     {
         this.OnDispose((Dispose)command);
     }
     else
     {
         throw new AmqpException(ErrorCode.NotImplemented,
             Fx.Format(SRAmqp.AmqpOperationNotSupported, command.Descriptor.Name));
     }
 }
示例#13
0
 static void EncodeFrame(ByteBuffer buffer, FrameType type, ushort channel, DescribedList command)
 {
     AmqpBitConverter.WriteUInt(buffer, 0u);
     AmqpBitConverter.WriteUByte(buffer, DOF);
     AmqpBitConverter.WriteUByte(buffer, (byte)type);
     AmqpBitConverter.WriteUShort(buffer, channel);
     Codec.Encode(command, buffer);
 }
            protected override DescribedList OnCommand(DescribedList command)
            {
                if (this.innerProfile == null)
                {
                    if (command.Descriptor.Code == Codec.SaslInit.Code)
                    {
                        var init = (SaslInit)command;
                        SaslMechanism saslMechanism;
                        if (!this.listener.saslSettings.TryGetMechanism(init.Mechanism, out saslMechanism))
                        {
                            throw new AmqpException(ErrorCode.NotImplemented, init.Mechanism);
                        }

                        this.innerProfile = saslMechanism.CreateProfile();
                    }
                    else
                    {
                        throw new AmqpException(ErrorCode.NotAllowed, command.Descriptor.Name);
                    }
                }

                return this.innerProfile.OnCommandInternal(command);
            }
 protected override DescribedList OnCommand(DescribedList command)
 {
     return null;
 }
示例#16
0
 internal void SendCommand(DescribedList command)
 {
     if (command.Descriptor.Code == Codec.End.Code || this.state < State.EndSent)
     {
         this.connection.SendCommand(this.channel, command);
     }
 }