Esempio n. 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;
 }
Esempio n. 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);
 }
Esempio n. 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());
            }
Esempio n. 4
0
        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());
        }
Esempio n. 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;
     }
 }
Esempio n. 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);
 }
Esempio n. 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);
Esempio n. 8
0
 internal DescribedList OnCommandInternal(DescribedList command)
 {
     return this.OnCommand(command);
 }
Esempio n. 9
0
 void OnSessionCommand(ushort remoteChannel, DescribedList command, ByteBuffer buffer)
 {
     this.GetSession(this.remoteSessions, remoteChannel).OnCommand(command, buffer);
 }
Esempio n. 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);
 }
Esempio n. 11
0
 internal void SendCommand(DescribedList command)
 {
     this.connection.SendCommand(this.channel, command);
 }
Esempio n. 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));
     }
 }
Esempio n. 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);
 }
Esempio n. 14
0
            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);
            }
Esempio n. 15
0
 protected override DescribedList OnCommand(DescribedList command)
 {
     return null;
 }
Esempio n. 16
0
 internal void SendCommand(DescribedList command)
 {
     if (command.Descriptor.Code == Codec.End.Code || this.state < State.EndSent)
     {
         this.connection.SendCommand(this.channel, command);
     }
 }