예제 #1
0
            protected override async Task InitializeAsync(IMessageBufferReader reader, CancellationToken cancellationToken)
            {
                await base.InitializeAsync(reader, cancellationToken);

                Value = await reader.PushByteFromStreamAsync(cancellationToken) == 0xFF;

                if (await reader.PushByteFromStreamAsync(cancellationToken) != 0x00)
                {
                    throw new InvalidOperationException();
                }
            }
예제 #2
0
            protected override async Task InitializeAsync(IMessageBufferReader reader, CancellationToken cancellationToken)
            {
                await base.InitializeAsync(reader, cancellationToken);

                Count = await reader.PushShortFromStreamAsync(cancellationToken);

                var byteCount = await reader.PushByteFromStreamAsync(cancellationToken);

                await reader.PushFromStreamAsync(byteCount, cancellationToken);

                MessageBuffer = new MessageBufferSpan(reader.Buffer, (ushort)(reader.Buffer.Length - byteCount - 2), byteCount);
            }
예제 #3
0
 public static async Task <int> PushShortFromStreamAsync(this IMessageBufferReader reader, CancellationToken cancellationToken)
 => (int)((await reader.PushByteFromStreamAsync(cancellationToken) << 8) + (await reader.PushByteFromStreamAsync(cancellationToken) << 0));