// Creates an outgoing frame (packet) public Frame(FrameType type, ushort channel, Performative command) { this.Type = type; this.Channel = channel; this.Command = command; this.dataOffset = Frame.DefaultDataOffset; this.size = HeaderSize; if (this.Command != null) { this.size += AmqpCodec.GetSerializableEncodeSize(this.Command) + this.Command.PayloadSize; } }
public void WriteFrame(Performative command, bool needReply) { try { Frame frame = new Frame(FrameType.Sasl, 0, command); TransportAsyncCallbackArgs args = new TransportAsyncCallbackArgs(); args.SetBuffer(frame.Buffer); args.CompletedCallback = this.onWriteFrameComplete; args.UserToken = needReply; this.writer.WriteBuffer(args); } catch (Exception exception) { this.HandleException(exception); } }
public static ByteBuffer EncodeCommand(FrameType type, ushort channel, Performative command, int payloadSize) { int serializableEncodeSize = 8; if (command != null) { serializableEncodeSize = serializableEncodeSize + AmqpCodec.GetSerializableEncodeSize(command); } serializableEncodeSize = serializableEncodeSize + payloadSize; ByteBuffer byteBuffer = new ByteBuffer(serializableEncodeSize, false, false); AmqpBitConverter.WriteUInt(byteBuffer, (uint)serializableEncodeSize); AmqpBitConverter.WriteUByte(byteBuffer, 2); AmqpBitConverter.WriteUByte(byteBuffer, (byte)type); AmqpBitConverter.WriteUShort(byteBuffer, channel); if (command != null) { AmqpCodec.EncodeSerializable(command, byteBuffer); } return(byteBuffer); }
public void SendCommand(Performative command, ushort channel, Action<object> callback, object state) { Frame frame = new Frame(FrameType.Amqp, channel, command); Utils.Trace(TraceLevel.Frame, "SEND {0}", frame); this.AsyncIO.Writer.WriteBuffer(frame.Buffer, command.PayloadList, callback, state); this.active = true; }
public void SendCommand(Performative command, ushort channel) { this.SendCommand(command, channel, null, null); }
void HandleSaslCommand(Performative command) { Utils.Trace(TraceLevel.Verbose, "{0}: Handle SASL command {1}", this.transport, command); if (command.DescriptorCode == SaslMechanisms.Code) { this.OnSaslServerMechanisms((SaslMechanisms)command); } else if (command.DescriptorCode == SaslInit.Code) { this.OnSaslInit((SaslInit)command); } else if (command.DescriptorCode == SaslChallenge.Code) { this.saslHandler.OnChallenge((SaslChallenge)command); } else if (command.DescriptorCode == SaslResponse.Code) { this.saslHandler.OnResponse((SaslResponse)command); } else if (command.DescriptorCode == SaslOutcome.Code) { this.OnSaslOutcome((SaslOutcome)command); } else { throw new AmqpException(AmqpError.NotAllowed, command.ToString()); } }
void WriteCommand(Performative command) { Frame frame = new Frame(FrameType.Amqp, 0, command); ByteBuffer byteBuffer = ByteBuffer.Wrap(Frame.HeaderSize + command.EncodeSize); frame.Encode(byteBuffer); this.AsyncIO.Writer.WriteBuffer(frame.Buffer, command.PayloadList, null, null); }
void SendCommand(Performative command, Action<object> callback, object state) { this.connection.SendCommand(command, this.LocalChannel, callback, state); Utils.Trace(TraceLevel.Debug, "{0}: Sent command {1}", this, command); if (command.DescriptorCode == Disposition.Code) { this.diagnostics.SendDisposition(); Disposition disposition = (Disposition)command; this.diagnostics.SetLastDisposition(disposition.Last == null ? disposition.First.Value : disposition.Last.Value); Utils.Trace(TraceLevel.Verbose, "{0}: Dispose {1}-{2}, settled:{3}, outcome:{4}.", this, disposition.First.Value, disposition.Last, disposition.Settled, disposition.State.DescriptorName.Value); } else if (command.DescriptorCode == Flow.Code) { this.diagnostics.SendFlow(); } else if (command.DescriptorCode == Transfer.Code) { this.diagnostics.SendTransfer(); } }
public void SendCommand(Performative command) { this.SendCommand(command, null, null); }