public async Task Send_Declare(string queueName, bool passive, bool durable, bool exclusive, bool autoDelete, Dictionary <string, object> arguments) { var buffer = await socket.GetWriteBuffer(); try { WritePayload(); await buffer.FlushAsync(); } finally { socket.ReleaseWriteBuffer(); } void WritePayload() { var writer = new CustomBufferWriter <PipeWriter>(buffer); var payloadSizeHeader = writer.WriteFrameHeader(FrameType.Method, channelNumber); writer.Write(Method.Queue.Declare); writer.Write(Reserved); writer.Write(Reserved); writer.WriteShortString(queueName); writer.WriteBits(passive, durable, exclusive, autoDelete); writer.WriteTable(arguments); writer.Commit(); BinaryPrimitives.WriteUInt32BigEndian(payloadSizeHeader, ((uint)writer.BytesCommitted - FrameHeaderSize)); writer.Write(FrameEnd); writer.Commit(); } }
public async Task Send_StartOk(string connectionName, string userName, string password, string mechanism = "PLAIN", string locale = "en_US") { var buffer = await socket.GetWriteBuffer(); try { WritePayload(); await buffer.FlushAsync(); } finally { socket.ReleaseWriteBuffer(); } void WritePayload() { var writer = new CustomBufferWriter <PipeWriter>(buffer); var payloadSizeHeader = writer.WriteFrameHeader(FrameType.Method, connectionChannelNumber); writer.Write(Method.Connection.StartOk); var clientProperties = new Dictionary <string, object> { { "product", "Angora" }, { "capabilities", capabilities }, { "connection_name", connectionName } }; writer.WriteTable(clientProperties); writer.WriteShortString(mechanism); writer.WriteLongString($"\0{userName}\0{password}"); //response writer.WriteShortString(locale); writer.Commit(); BinaryPrimitives.WriteUInt32BigEndian(payloadSizeHeader, ((uint)writer.BytesCommitted - FrameHeaderSize)); writer.Write(FrameEnd); writer.Commit(); } }
public async Task Send_Bind(string source, string destination, string routingKey, Dictionary <string, object> arguments) { var buffer = await socket.GetWriteBuffer(); try { WritePayload(); await buffer.FlushAsync(); } finally { socket.ReleaseWriteBuffer(); } void WritePayload() { var writer = new CustomBufferWriter <PipeWriter>(buffer); var payloadSizeHeader = writer.WriteFrameHeader(FrameType.Method, channelNumber); writer.Write(Method.Exchange.Bind); writer.Write(Reserved); writer.Write(Reserved); writer.WriteShortString(source); writer.WriteShortString(destination); writer.WriteShortString(routingKey); writer.WriteBits(); writer.WriteTable(arguments); writer.Commit(); BinaryPrimitives.WriteUInt32BigEndian(payloadSizeHeader, ((uint)writer.BytesCommitted - FrameHeaderSize)); writer.Write(FrameEnd); writer.Commit(); } }