Exemplo n.º 1
0
        protected override void WriteFramingExtras(OperationBuilder builder)
        {
            if (PreserveTtl)
            {
                Span <byte> preserveTtlByte = stackalloc byte[1];
                preserveTtlByte[0] = 5 << 4;
                builder.Write(preserveTtlByte);
            }

            if (DurabilityLevel == DurabilityLevel.None)
            {
                return;
            }

            // TODO: omit timeout bytes if no timeout provided
            Span <byte> bytes = stackalloc byte[2];

            var framingExtra = new FramingExtraInfo(RequestFramingExtraType.DurabilityRequirements, (byte)(bytes.Length - 1));

            bytes[0] = framingExtra.Byte;
            bytes[1] = (byte)DurabilityLevel;

            // TODO: improve timeout, coerce to 1500ms, etc
            //var timeout = DurabilityTimeout.HasValue ? DurabilityTimeout.Value.TotalMilliseconds : 0;
            //Converter.FromUInt16((ushort)timeout, bytes, 2);

            builder.Write(bytes);
        }
        public void Encodes(RequestFramingExtraType type, byte length)
        {
            var framingExtra = new FramingExtraInfo(type, length);

            Assert.Equal(type, (RequestFramingExtraType)framingExtra.Type);
            Assert.Equal(length, (ushort)framingExtra.Length);
        }
        public override byte[] CreateFramingExtras()
        {
            if (DurabilityLevel == DurabilityLevel.None)
            {
                return(new byte[0]);
            }

            // TODO: omit timeout bytes if no timeout provided
            var bytes = new byte[2];

            var framingExtra = new FramingExtraInfo(RequestFramingExtraType.DurabilityRequirements, (byte)(bytes.Length - 1));

            Converter.FromByte(framingExtra.Byte, bytes, 0);
            Converter.FromByte((byte)DurabilityLevel, bytes, 1);

            // TODO: improve timeout, coerce to 1500ms, etc
            //var timeout = DurabilityTimeout.HasValue ? DurabilityTimeout.Value.TotalMilliseconds : 0;
            //Converter.FromUInt16((ushort)timeout, bytes, 2);

            return(bytes);
        }
Exemplo n.º 4
0
        public override void WriteFramingExtras(OperationBuilder builder)
        {
            if (DurabilityLevel == DurabilityLevel.None)
            {
                return;
            }

            // TODO: omit timeout bytes if no timeout provided
            Span <byte> bytes = stackalloc byte[2];

            var framingExtra = new FramingExtraInfo(RequestFramingExtraType.DurabilityRequirements, (byte)(bytes.Length - 1));

            Converter.FromByte(framingExtra.Byte, bytes);
            Converter.FromByte((byte)DurabilityLevel, bytes.Slice(1));

            // TODO: improve timeout, coerce to 1500ms, etc
            //var timeout = DurabilityTimeout.HasValue ? DurabilityTimeout.Value.TotalMilliseconds : 0;
            //Converter.FromUInt16((ushort)timeout, bytes, 2);

            builder.Write(bytes);
        }