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; }
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); }
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()); }
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; } }
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); }
/// <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);
internal DescribedList OnCommandInternal(DescribedList command) { return this.OnCommand(command); }
void OnSessionCommand(ushort remoteChannel, DescribedList command, ByteBuffer buffer) { this.GetSession(this.remoteSessions, remoteChannel).OnCommand(command, buffer); }
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); }
internal void SendCommand(DescribedList command) { this.connection.SendCommand(this.channel, command); }
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)); } }
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; }
internal void SendCommand(DescribedList command) { if (command.Descriptor.Code == Codec.End.Code || this.state < State.EndSent) { this.connection.SendCommand(this.channel, command); } }