Exemplo n.º 1
0
        public void WriteMessage(QueueInfo message, IBufferWriter <byte> output)
        {
            ValueWriter writer = new ValueWriter(output);

            writer.WriteOctet(1);
            writer.WriteShortInt(ChannelId);
            var reseved    = writer.Reserve(4);
            var checkpoint = writer.Written;

            FrameWriter.WriteMethodFrame(50, 10, ref writer);
            writer.WriteShortInt(0); //reserved-1
            writer.WriteShortStr(message.Name);
            writer.WriteBit(message.Passive);
            writer.WriteBit(message.Durable);
            writer.WriteBit(message.Exclusive);
            writer.WriteBit(message.AutoDelete);
            writer.WriteBit(message.NoWait);
            writer.WriteTable(message.Arguments);
            var payloadSize = writer.Written - checkpoint;

            writer.WriteOctet(Constants.FrameEnd);

            Span <byte> span = stackalloc byte[4];

            BinaryPrimitives.WriteInt32BigEndian(span, payloadSize);
            reseved.Write(span);

            writer.Commit();
        }
        public void WriteMessage(QueueDelete message, IBufferWriter <byte> output)
        {
            ValueWriter writer = new ValueWriter(output);

            writer.WriteOctet(RabbitMQConstants.FrameMethod);
            writer.WriteShortInt(_channelId);
            var reserved   = writer.Reserve(4);
            var checkpoint = writer.Written;

            FrameWriter.WriteMethodFrame(50, 40, ref writer);
            writer.WriteShortInt(0); //reserved-1
            writer.WriteShortStr(message.Name);
            writer.WriteBit(message.IfUnused);
            writer.WriteBit(message.IfEmpty);
            writer.WriteBit(message.NoWait);
            writer.BitFlush();
            var payloadSize = writer.Written - checkpoint;

            writer.WriteOctet(RabbitMQConstants.FrameEnd);

            Span <byte> span = stackalloc byte[4];

            BinaryPrimitives.WriteInt32BigEndian(span, payloadSize);
            reserved.Write(span);

            writer.Commit();
        }
Exemplo n.º 3
0
        public void WriteMessage(QueueBind message, IBufferWriter <byte> output)
        {
            ValueWriter writer = new ValueWriter(output);

            writer.WriteOctet(1);
            writer.WriteShortInt(_channelId);
            var reserved   = writer.Reserve(4);
            var checkpoint = writer.Written;

            FrameWriter.WriteMethodFrame(50, 20, ref writer);
            writer.WriteShortInt(0); //reserved-1
            writer.WriteShortStr(message.QueueName);
            writer.WriteShortStr(message.ExchangeName);
            writer.WriteShortStr(message.RoutingKey);
            writer.WriteBit(message.NoWait);
            writer.WriteTable(message.Arguments);
            var payloadSize = writer.Written - checkpoint;

            writer.WriteOctet(RabbitMQConstants.FrameEnd);

            Span <byte> span = stackalloc byte[4];

            BinaryPrimitives.WriteInt32BigEndian(span, payloadSize);
            reserved.Write(span);

            writer.Commit();
        }
        public void WriteMessage(ExchangeDeclare message, IBufferWriter <byte> output)
        {
            ValueWriter writer = new ValueWriter(output);

            writer.WriteOctet(1);
            writer.WriteShortInt(_channelId);
            var reserved   = writer.Reserve(4);
            var checkpoint = writer.Written;

            FrameWriter.WriteMethodFrame(40, 10, ref writer);
            writer.WriteShortInt(0); //reseved-1
            writer.WriteShortStr(message.Name);
            writer.WriteShortStr(message.Type);

            writer.WriteBit(message.Passive);
            writer.WriteBit(message.Durable);
            writer.WriteBit(message.AutoDelete);
            writer.WriteBit(message.Internal);
            writer.WriteBit(message.NoWait);
            writer.WriteTable(message.Arguments);
            var size = writer.Written - checkpoint;

            writer.WriteOctet(RabbitMQConstants.FrameEnd);

            Span <byte> sizeSpan = stackalloc byte[4];

            BinaryPrimitives.WriteInt32BigEndian(sizeSpan, size);
            reserved.Write(sizeSpan);

            writer.Commit();
        }
Exemplo n.º 5
0
        public void WriteMessage(NoPaylodMethodInfo message, IBufferWriter <byte> output)
        {
            var writer = new ValueWriter(output);

            FrameWriter.WriteFrameHeader(message.FrameType, message.Channel, 4, ref writer);
            FrameWriter.WriteMethodFrame(message.ClassId, message.MethodId, ref writer);
            writer.WriteOctet(RabbitMQConstants.FrameEnd);
            writer.Commit();
        }
Exemplo n.º 6
0
        public void WriteMessage(ushort message, IBufferWriter <byte> output)
        {
            ValueWriter writer = new ValueWriter(output);

            FrameWriter.WriteFrameHeader(1, message, 5, ref writer);
            FrameWriter.WriteMethodFrame(20, 10, ref writer);
            writer.WriteOctet(0);
            writer.WriteOctet(206);
            writer.Commit();
        }
Exemplo n.º 7
0
        public void WriteMessage(RejectInfo message, IBufferWriter <byte> output)
        {
            ValueWriter writer = new ValueWriter(output);

            FrameWriter.WriteFrameHeader(Constants.FrameMethod, _channel, 13, ref writer);
            FrameWriter.WriteMethodFrame(60, 90, ref writer);
            writer.WriteLongLong(message.DeliveryTag);
            writer.WriteBit(message.Requeue);
            writer.WriteOctet(Constants.FrameEnd);
        }
Exemplo n.º 8
0
        public void WriteMessage(RabbitMQMainInfo message, IBufferWriter <byte> output)
        {
            ValueWriter writer = new ValueWriter(output);

            FrameWriter.WriteFrameHeader(1, 0, 12, ref writer);
            FrameWriter.WriteMethodFrame(10, 31, ref writer);
            writer.WriteShortInt(message.ChannelMax);
            writer.WriteLong(message.FrameMax);
            writer.WriteShortInt(message.Heartbeat);
            writer.WriteOctet(206);
            writer.Commit();
        }
        public void WriteMessage(AckInfo message, IBufferWriter <byte> output)
        {
            ValueWriter writer = new ValueWriter(output);

            FrameWriter.WriteFrameHeader(Constants.FrameMethod, _channelId, 13, ref writer);
            FrameWriter.WriteMethodFrame(60, 80, ref writer);
            writer.WriteLongLong(message.DeliveryTag);
            writer.WriteBit(message.Multiple);
            writer.BitFlush();
            writer.WriteOctet(Constants.FrameEnd);
            writer.Commit();
        }
Exemplo n.º 10
0
        public void WriteMessage(QoSInfo message, IBufferWriter <byte> output)
        {
            ValueWriter writer = new ValueWriter(output);

            FrameWriter.WriteFrameHeader(1, _channel, 11, ref writer);
            FrameWriter.WriteMethodFrame(60, 10, ref writer);
            writer.WriteLong(message.PrefetchSize);
            writer.WriteShortInt(message.PrefetchCount);
            writer.WriteBool(message.Global);
            writer.WriteOctet(RabbitMQConstants.FrameEnd);

            writer.Commit();
        }
Exemplo n.º 11
0
        internal void WriteMessage(ref BasicPublishInfo message, ref ValueWriter writer)
        {
            var payloadSize = 9 + message.ExchangeName.Length + message.RoutingKey.Length;

            FrameWriter.WriteFrameHeader(RabbitMQConstants.FrameMethod, _channelid, payloadSize, ref writer);
            //var checkpoint = writer.Written;
            FrameWriter.WriteMethodFrame(60, 40, ref writer);
            writer.WriteShortInt(0); //reserved-1
            writer.WriteShortStr(message.ExchangeName);
            writer.WriteShortStr(message.RoutingKey);
            writer.WriteBit(message.Mandatory);
            writer.WriteBit(message.Immediate);
            writer.BitFlush();
            //var size = writer.Written - checkpoint;
            writer.WriteOctet(RabbitMQConstants.FrameEnd);
            writer.Commit();
        }
Exemplo n.º 12
0
        public void WriteMessage(BasicPublishInfo message, IBufferWriter <byte> output)
        {
            ValueWriter writer      = new ValueWriter(output);
            var         payloadSize = 9 + message.ExchangeName.Length + message.RoutingKey.Length;

            FrameWriter.WriteFrameHeader(Constants.FrameMethod, _channelid, payloadSize, ref writer);
            //var checkpoint = writer.Written;
            FrameWriter.WriteMethodFrame(60, 40, ref writer);
            writer.WriteShortInt(0); //reserved-1
            writer.WriteShortStr(message.ExchangeName);
            writer.WriteShortStr(message.RoutingKey);
            writer.WriteBit(message.Mandatory);
            writer.WriteBit(message.Immediate);
            writer.BitFlush();
            //var size = writer.Written - checkpoint;
            writer.WriteOctet(Constants.FrameEnd);
            writer.Commit();
        }
Exemplo n.º 13
0
        public void WriteMessage(PublishAllInfo message, IBufferWriter <byte> output)
        {
            var writer = new ValueWriter(output);

            var framePayloadSize = 9 + message.Info.ExchangeName.Length + message.Info.RoutingKey.Length;

            FrameWriter.WriteFrameHeader(RabbitMQConstants.FrameMethod, message.ChannelId, framePayloadSize, ref writer);
            FrameWriter.WriteMethodFrame(60, 40, ref writer);
            writer.WriteShortInt(0); //reserved-1
            writer.WriteShortStr(message.Info.ExchangeName);
            writer.WriteShortStr(message.Info.RoutingKey);
            writer.WriteBit(message.Info.Mandatory);
            writer.WriteBit(message.Info.Immediate);
            writer.BitFlush();
            writer.WriteOctet(RabbitMQConstants.FrameEnd);

            _bitCount = 0;
            _flagWord = 0;
            writer.WriteOctet(RabbitMQConstants.FrameHeader);
            writer.WriteShortInt(message.ChannelId);
            var reserved   = writer.Reserve(4);
            var checkpoint = writer.Written;

            writer.WriteShortInt(message.Header.ClassId);
            writer.WriteShortInt(message.Header.Weight);
            writer.WriteLongLong(message.Header.BodySize);
            WriteBitFlagsAndContinuation(ref message.Header.Properties, ref writer);
            var payloadSize = writer.Written - checkpoint;

            writer.WriteOctet(RabbitMQConstants.FrameEnd);
            Span <byte> span = stackalloc byte[4];

            BinaryPrimitives.WriteInt32BigEndian(span, payloadSize);
            reserved.Write(span);

            FrameWriter.WriteFrameHeader(RabbitMQConstants.FrameBody, message.ChannelId, message.Body.Length, ref writer);
            writer.WriteBytes(message.Body.Span);
            writer.WriteOctet(RabbitMQConstants.FrameEnd);


            writer.Commit();
        }
        public void WriteMessage(string message, IBufferWriter <byte> output)
        {
            ValueWriter writer = new ValueWriter(output);

            writer.WriteOctet(1);
            writer.WriteShortInt(0);
            var reserved   = writer.Reserve(4);
            var checkpoint = writer.Written;

            FrameWriter.WriteMethodFrame(10, 40, ref writer);
            writer.WriteShortStr(message);
            writer.WriteOctet(0);
            writer.WriteOctet(0);
            var paylodaSize = writer.Written - checkpoint;

            writer.WriteOctet(206);
            Span <byte> bytes = stackalloc byte[4];

            BinaryPrimitives.WriteInt32BigEndian(bytes, paylodaSize);
            reserved.Write(bytes);
            writer.Commit();
        }
        public void WriteMessage(ConsumeCancelInfo message, IBufferWriter <byte> output)
        {
            ValueWriter writer = new ValueWriter(output);

            writer.WriteOctet(1);
            writer.WriteShortInt(_channelId);
            var reserved   = writer.Reserve(4);
            var checkpoint = writer.Written;

            FrameWriter.WriteMethodFrame(60, 30, ref writer);
            writer.WriteShortStr(message.ConsumerTag);
            writer.WriteBool(message.NoWait);
            var payloadSize = writer.Written - checkpoint;

            writer.WriteOctet(RabbitMQConstants.FrameEnd);

            Span <byte> sizeSpan = stackalloc byte[4];

            BinaryPrimitives.WriteInt32BigEndian(sizeSpan, 18);
            reserved.Write(sizeSpan);

            writer.Commit();
        }
Exemplo n.º 16
0
        public void WriteMessage(CloseInfo message, IBufferWriter <byte> output)
        {
            ValueWriter writer = new ValueWriter(output);

            writer.WriteOctet(1);
            writer.WriteShortInt(message.ChannelId);
            var reserved   = writer.Reserve(4);
            var checkpoint = writer.Written;

            FrameWriter.WriteMethodFrame(20, 40, ref writer);
            writer.WriteShortInt(message.ReplyCode);
            writer.WriteShortStr(message.ReplyText);
            writer.WriteShortInt(message.FailedClassId);
            writer.WriteShortInt(message.FailedMethodId);
            var size = writer.Written - checkpoint;

            writer.WriteOctet(206);
            Span <byte> sizeSpan = stackalloc byte[4];

            BinaryPrimitives.WriteInt32BigEndian(sizeSpan, size);
            reserved.Write(sizeSpan);
            writer.Commit();
        }
        public void WriteMessage(ClientConf message, IBufferWriter <byte> output)
        {
            var writer = new ValueWriter(output);

            writer.WriteOctet(1);
            writer.WriteShortInt(0);
            var reserved   = writer.Reserve(4);
            var checkpoint = writer.Written;

            FrameWriter.WriteMethodFrame(10, 11, ref writer);
            writer.WriteTable(message.Properties);
            writer.WriteShortStr(message.Mechanism);
            writer.WriteLongStr($"\0{_info.User}\0{_info.Password}");
            writer.WriteShortStr(message.Locale);
            var paylodaSize = writer.Written - checkpoint;

            writer.WriteOctet(206);

            Span <byte> bytes = stackalloc byte[4];

            BinaryPrimitives.WriteInt32BigEndian(bytes, paylodaSize);
            reserved.Write(bytes);
            writer.Commit();
        }