public void Decrypt(ReadOnlySequence <byte> sequence, Action <ReadOnlySequence <byte> > action) { var bytesPipe = new BytesPipe(_bytesPool); Span <byte> payloadLengthBytes = stackalloc byte[4]; Span <byte> tag = stackalloc byte[TagLength]; var buffer = _bytesPool.Array.Rent(MaxPayloadLength); try { while (sequence.Length > 4 + TagLength) { sequence.Slice(0, payloadLengthBytes.Length).CopyTo(payloadLengthBytes); sequence = sequence.Slice(payloadLengthBytes.Length); var payloadLength = BinaryPrimitives.ReadInt32BigEndian(payloadLengthBytes); if (payloadLength > MaxPayloadLength) { throw new OmniSecureConnectionException("payload too large"); } sequence.Slice(0, tag.Length).CopyTo(tag); sequence = sequence.Slice(tag.Length); var ciphertext = buffer.AsSpan()[..payloadLength];
private static OmniHash CreateOmniHash(string name, ReadOnlySpan <byte> publicKey, OmniHashAlgorithmType hashAlgorithmType) { if (name == null) { throw new ArgumentNullException(nameof(name)); } using var bytesPipe = new BytesPipe(); { var writer = new RocketMessageWriter(bytesPipe.Writer, BytesPool.Shared); writer.Write(name); writer.Write(publicKey); } if (hashAlgorithmType == OmniHashAlgorithmType.Sha2_256) { var result = new OmniHash(hashAlgorithmType, Sha2_256.ComputeHash(bytesPipe.Reader.GetSequence())); return(result); } else { throw new NotSupportedException(); } }
public static string SignatureToString(OmniSignature signature) { using var bytesPipe = new BytesPipe(BytesPool.Shared); signature.Export(bytesPipe.Writer, BytesPool.Shared); var hash = new OmniHash(OmniHashAlgorithmType.Sha2_256, Sha2_256.ComputeHash(bytesPipe.Reader.GetSequence())); return(hash.ToString(ConvertStringType.Base16)); }
public ConnectionSender(ICap cap, IBytesPool bytesPool, CancellationToken cancellationToken) { _cap = cap; _bytesPool = bytesPool; _cancellationToken = cancellationToken; _bytesPipe = new BytesPipe(_bytesPool); _semaphoreSlim = new SemaphoreSlim(1, 1); }
public ConnectionReceiver(ICap cap, int maxReceiveByteCount, IBytesPool bytesPool, CancellationToken cancellationToken) { _cap = cap; _maxReceiveByteCount = maxReceiveByteCount; _bytesPool = bytesPool; _cancellationToken = cancellationToken; _bytesPipe = new BytesPipe(_bytesPool); _semaphoreSlim = new SemaphoreSlim(0, 1); }
public bool Verify() { using var bytesPipe = new BytesPipe(); var target = new AuthenticationMessage(this.CreationTime, this.Hash, null); target.Export(bytesPipe.Writer, BytesPool.Shared); return(this.Certificate?.Verify(bytesPipe.Reader.GetSequence()) ?? false); }
public static async ValueTask <TValue?> TryGetValueAsync <TValue>(this IKeyValueStorage <string> storage, string key, CancellationToken cancellationToken = default) where TValue : IRocketMessage <TValue> { var bytesPool = BytesPool.Shared; using var bytesPipe = new BytesPipe(bytesPool); if (!await storage.TryReadAsync(key, bytesPipe.Writer, cancellationToken)) { return(default);
public static Shout Create(Timestamp creationTime, IMemoryOwner <byte> value, OmniDigitalSignature digitalSignature) { using var bytesPipe = new BytesPipe(); var target = new Shout(creationTime, value, null); target.Export(bytesPipe.Writer, BytesPool.Shared); var certificate = OmniDigitalSignature.CreateOmniCertificate(digitalSignature, bytesPipe.Reader.GetSequence()); return(new Shout(creationTime, value, certificate)); }
private static bool TryEncode(byte[] body, out byte[]?message) { message = null; using var bytesPipe = new BytesPipe(); if (!OmniMessageConverter.TryWrite(new ReadOnlySequence <byte>(body), bytesPipe.Writer)) { return(false); } message = bytesPipe.Reader.GetSequence().ToArray(); return(true); }
private static bool TryDecode(byte[] message, out byte[]?body) { body = null; using var bytesPipe = new BytesPipe(); if (!OmniMessageConverter.TryRead(new ReadOnlySequence <byte>(message), bytesPipe.Writer)) { return(false); } body = bytesPipe.Reader.GetSequence().ToArray(); return(true); }
public static IMemoryOwner <byte> ToBytes <T>(T message) where T : IRocketMessage <T> { using var hub = new BytesPipe(); message.Export(hub.Writer, BytesPool.Shared); var sequence = hub.Reader.GetSequence(); var memoryOwner = BytesPool.Shared.Memory.Rent((int)sequence.Length).Shrink((int)sequence.Length); sequence.CopyTo(memoryOwner.Memory.Span); return(memoryOwner); }
public void EmptyDataGetTest() { using var bytesPipe = new BytesPipe(); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Assert.False(Varint.TryGetUInt8(ref reader, out var result1)); Assert.False(Varint.TryGetUInt16(ref reader, out var result2)); Assert.False(Varint.TryGetUInt32(ref reader, out var result3)); Assert.False(Varint.TryGetUInt64(ref reader, out var result4)); Assert.False(Varint.TryGetInt8(ref reader, out var result5)); Assert.False(Varint.TryGetInt16(ref reader, out var result6)); Assert.False(Varint.TryGetInt32(ref reader, out var result7)); Assert.False(Varint.TryGetInt64(ref reader, out var result8)); }
private byte[] ComputeHash(ProfileMessage profileMessage, OmniAgreementPublicKey agreementPublicKey, HashAlgorithmType hashAlgorithm) { var verificationMessage = new VerificationMessage(profileMessage, agreementPublicKey); if (hashAlgorithm == HashAlgorithmType.Sha2_256) { using var bytesPipe = new BytesPipe(); verificationMessage.Export(bytesPipe.Writer, _bytesPool); return(Sha2_256.ComputeHash(bytesPipe.Reader.GetSequence())); } throw new NotSupportedException(nameof(hashAlgorithm)); }
public void Encrypt(Action <IBufferWriter <byte> > action, IBufferWriter <byte> bufferWriter) { using var bytesPipe = new BytesPipe(_bytesPool); action.Invoke(bytesPipe.Writer); var sequence = bytesPipe.Reader.GetSequence(); var buffer = _bytesPool.Array.Rent(MaxPayloadLength); try { while (sequence.Length > 0) { int payloadLength = (int)Math.Min(sequence.Length, MaxPayloadLength); var payloadLengthBytes = bufferWriter.GetSpan(4)[..4];
public static void ToStream <T>(T message, Stream stream) where T : IRocketMessage <T> { using var bytesPipe = new BytesPipe(); message.Export(bytesPipe.Writer, BytesPool.Shared); var sequence = bytesPipe.Reader.GetSequence(); var position = sequence.Start; while (sequence.TryGet(ref position, out var memory)) { stream.Write(memory.Span); } }
private ArraySegment <byte> GetPayload(Action <IBufferWriter <byte> > action) { using var bytesPipe = new BytesPipe(_bytesPool); action.Invoke(bytesPipe.Writer); if (bytesPipe.Writer.WrittenBytes == 0) { return(ArraySegment <byte> .Empty); } var sequence = bytesPipe.Reader.GetSequence(); var buffer = _bytesPool.Array.Rent((int)sequence.Length); sequence.CopyTo(buffer.AsSpan()); return(new ArraySegment <byte>(buffer, 0, (int)sequence.Length)); }
public static AuthenticationMessage Create(DateTime creationTime, ReadOnlyMemory <byte> hash, OmniDigitalSignature?digitalSignature) { if (digitalSignature is null) { return(new AuthenticationMessage(Timestamp.FromDateTime(creationTime), hash, null)); } using var bytesPipe = new BytesPipe(); var target = new AuthenticationMessage(Timestamp.FromDateTime(creationTime), hash, null); target.Export(bytesPipe.Writer, BytesPool.Shared); var certificate = OmniDigitalSignature.CreateOmniCertificate(digitalSignature, bytesPipe.Reader.GetSequence()); return(new AuthenticationMessage(Timestamp.FromDateTime(creationTime), hash, certificate)); }
private static string MessageToString <T>(string path, int version, T message) where T : IRocketMessage <T> { var bytesPool = BytesPool.Shared; using var inBytesPipe = new BytesPipe(bytesPool); message.Export(inBytesPipe.Writer, bytesPool); using var outBytesPipe = new BytesPipe(bytesPool); if (!OmniMessageConverter.TryWrite(inBytesPipe.Reader.GetSequence(), outBytesPipe.Writer)) { throw new Exception(); } return(AddSchemaAndPath(path, version, OmniBase.Encode(outBytesPipe.Reader.GetSequence(), ConvertStringType.Base58) !)); }
public static T FromStream <T>(Stream inStream) where T : IRocketMessage <T> { using var bytesPipe = new BytesPipe(); const int bufferSize = 4096; while (inStream.Position < inStream.Length) { var readLength = inStream.Read(bytesPipe.Writer.GetSpan(bufferSize)); if (readLength < 0) { break; } bytesPipe.Writer.Advance(readLength); } return(IRocketMessage <T> .Import(bytesPipe.Reader.GetSequence(), BytesPool.Shared)); }
public static async IAsyncEnumerable <TValue> GetValuesAsync <TValue>(this IKeyValueStorage <string> storage, [EnumeratorCancellation] CancellationToken cancellationToken = default) where TValue : IRocketMessage <TValue> { var bytesPool = BytesPool.Shared; using var bytesPipe = new BytesPipe(bytesPool); await foreach (var key in storage.GetKeysAsync(cancellationToken)) { if (!await storage.TryReadAsync(key, bytesPipe.Writer, cancellationToken)) { continue; } var value = IRocketMessage <TValue> .Import(bytesPipe.Reader.GetSequence(), bytesPool); yield return(value); bytesPipe.Reset(); } }
public void BrokenDataGetTest() { const byte Int8Code = 0x80; const byte Int16Code = 0x81; const byte Int32Code = 0x82; const byte Int64Code = 0x83; { using var bytesPipe = new BytesPipe(); bytesPipe.Writer.Write(new byte[] { Int8Code }); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Assert.False(Varint.TryGetUInt8(ref reader, out var result1)); } { { using var bytesPipe = new BytesPipe(); bytesPipe.Writer.Write(new byte[] { Int8Code }); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Assert.False(Varint.TryGetUInt16(ref reader, out var result1)); } { using var bytesPipe = new BytesPipe(); bytesPipe.Writer.Write(new byte[] { Int16Code }); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Assert.False(Varint.TryGetUInt16(ref reader, out var result1)); } } { { using var bytesPipe = new BytesPipe(); bytesPipe.Writer.Write(new byte[] { Int8Code }); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Assert.False(Varint.TryGetUInt32(ref reader, out var result1)); } { using var bytesPipe = new BytesPipe(); bytesPipe.Writer.Write(new byte[] { Int16Code }); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Assert.False(Varint.TryGetUInt32(ref reader, out var result1)); } { using var bytesPipe = new BytesPipe(); bytesPipe.Writer.Write(new byte[] { Int32Code }); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Assert.False(Varint.TryGetUInt32(ref reader, out var result1)); } } { { using var bytesPipe = new BytesPipe(); bytesPipe.Writer.Write(new byte[] { Int8Code }); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Assert.False(Varint.TryGetUInt64(ref reader, out var result1)); } { using var bytesPipe = new BytesPipe(); bytesPipe.Writer.Write(new byte[] { Int16Code }); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Assert.False(Varint.TryGetUInt64(ref reader, out var result1)); } { using var bytesPipe = new BytesPipe(); bytesPipe.Writer.Write(new byte[] { Int32Code }); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Assert.False(Varint.TryGetUInt64(ref reader, out var result1)); } { using var bytesPipe = new BytesPipe(); bytesPipe.Writer.Write(new byte[] { Int64Code }); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Assert.False(Varint.TryGetUInt64(ref reader, out var result1)); } } }
public void RandomTest() { var random = new Random(0); using (var bytesPipe = new BytesPipe()) { for (int i = 0; i < 32; i++) { foreach (var result1 in GenRandomValue(random, 8).Select(n => (byte)n)) { Varint.SetUInt8(result1, bytesPipe.Writer); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Varint.TryGetUInt8(ref reader, out var result2); Assert.Equal(result1, result2); bytesPipe.Reset(); } } } using (var bytesPipe = new BytesPipe()) { for (int i = 0; i < 32; i++) { foreach (var result1 in GenRandomValue(random, 16).Select(n => (ushort)n)) { Varint.SetUInt16(result1, bytesPipe.Writer); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Varint.TryGetUInt16(ref reader, out var result2); Assert.Equal(result1, result2); bytesPipe.Reset(); } } } using (var bytesPipe = new BytesPipe()) { for (int i = 0; i < 32; i++) { foreach (var result1 in GenRandomValue(random, 32).Select(n => (uint)n)) { Varint.SetUInt32(result1, bytesPipe.Writer); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Varint.TryGetUInt32(ref reader, out var result2); Assert.Equal(result1, result2); bytesPipe.Reset(); } } } using (var bytesPipe = new BytesPipe()) { for (int i = 0; i < 32; i++) { foreach (var result1 in GenRandomValue(random, 64).Select(n => (ulong)n)) { Varint.SetUInt64(result1, bytesPipe.Writer); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Varint.TryGetUInt64(ref reader, out var result2); Assert.Equal(result1, result2); bytesPipe.Reset(); } } } using (var bytesPipe = new BytesPipe()) { for (int i = 0; i < 32; i++) { foreach (var result1 in GenRandomValue(random, 8).Select(n => (sbyte)n)) { Varint.SetInt8(result1, bytesPipe.Writer); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Varint.TryGetInt8(ref reader, out var result2); Assert.Equal(result1, result2); bytesPipe.Reset(); } } } using (var bytesPipe = new BytesPipe()) { for (int i = 0; i < 32; i++) { foreach (var result1 in GenRandomValue(random, 16).Select(n => (short)n)) { Varint.SetInt16(result1, bytesPipe.Writer); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Varint.TryGetInt16(ref reader, out var result2); Assert.Equal(result1, result2); bytesPipe.Reset(); } } } using (var bytesPipe = new BytesPipe()) { for (int i = 0; i < 32; i++) { foreach (var result1 in GenRandomValue(random, 32).Select(n => (int)n)) { Varint.SetInt32(result1, bytesPipe.Writer); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Varint.TryGetInt32(ref reader, out var result2); Assert.Equal(result1, result2); bytesPipe.Reset(); } } } using (var bytesPipe = new BytesPipe()) { for (int i = 0; i < 32; i++) { foreach (var result1 in GenRandomValue(random, 64).Select(n => (long)n)) { Varint.SetInt64(result1, bytesPipe.Writer); var reader = new SequenceReader <byte>(bytesPipe.Reader.GetSequence()); Varint.TryGetInt64(ref reader, out var result2); Assert.Equal(result1, result2); bytesPipe.Reset(); } } } }
static StringDeserializeBenchmark() { var charList = new char[] { 'A', 'B', 'C', 'D', 'E', '安', '以', '宇', '衣', '於' }; string GetRandomString(Random random) { var sb = new StringBuilder(); for (int i = random.Next(32, 256) - 1; i >= 0; i--) { sb.Append(charList[random.Next(0, charList.Length)]); } return(sb.ToString()); } { var random = new Random(0); var elementsList = new List <MessagePack_StringElements>(); for (int i = 0; i < 32 * 1024; i++) { var elements = new MessagePack_StringElements() { X0 = GetRandomString(random), X1 = GetRandomString(random), X2 = GetRandomString(random), X3 = GetRandomString(random), X4 = GetRandomString(random), X5 = GetRandomString(random), X6 = GetRandomString(random), X7 = GetRandomString(random), X8 = GetRandomString(random), X9 = GetRandomString(random), }; elementsList.Add(elements); } _messagePack_Bytes = MessagePack.MessagePackSerializer.Serialize(new MessagePack_StringElementsList() { List = elementsList.ToArray() }); } { var random = new Random(0); var bytesPool = BytesPool.Shared; using (var bytesPipe = new BytesPipe(bytesPool)) { var elementsList = new List <RocketPack_StringElements>(); for (int i = 0; i < 32 * 1024; i++) { var X0 = GetRandomString(random); var X1 = GetRandomString(random); var X2 = GetRandomString(random); var X3 = GetRandomString(random); var X4 = GetRandomString(random); var X5 = GetRandomString(random); var X6 = GetRandomString(random); var X7 = GetRandomString(random); var X8 = GetRandomString(random); var X9 = GetRandomString(random); var elements = new RocketPack_StringElements(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9); elementsList.Add(elements); } var message = new RocketPack_StringElementsList(elementsList.ToArray()); message.Export(bytesPipe.Writer, BytesPool.Shared); _rocketPack_Bytes = new byte[bytesPipe.Writer.WrittenBytes]; bytesPipe.Reader.GetSequence().CopyTo(_rocketPack_Bytes); } } }
static IntSerializeBenchmark() { { var random = new Random(0); var elementsList = new List <MessagePack_IntElements>(); for (int i = 0; i < 32 * 1024; i++) { var elements = new MessagePack_IntElements() { X0 = (uint)random.Next(0, 1024 * 256), X1 = (uint)random.Next(0, 1024 * 256), X2 = (uint)random.Next(0, 1024 * 256), X3 = (uint)random.Next(0, 1024 * 256), X4 = (uint)random.Next(0, 1024 * 256), X5 = (uint)random.Next(0, 1024 * 256), X6 = (uint)random.Next(0, 1024 * 256), X7 = (uint)random.Next(0, 1024 * 256), X8 = (uint)random.Next(0, 1024 * 256), X9 = (uint)random.Next(0, 1024 * 256), }; elementsList.Add(elements); } _messagePack_Message = new MessagePack_IntElementsList() { List = elementsList.ToArray() }; } { var random = new Random(0); var bytesPool = BytesPool.Shared; using (var bytesPipe = new BytesPipe(bytesPool)) { var elementsList = new List <RocketPack_IntElements>(); for (int i = 0; i < 32 * 1024; i++) { var X0 = (uint)random.Next(0, 1024 * 256); var X1 = (uint)random.Next(0, 1024 * 256); var X2 = (uint)random.Next(0, 1024 * 256); var X3 = (uint)random.Next(0, 1024 * 256); var X4 = (uint)random.Next(0, 1024 * 256); var X5 = (uint)random.Next(0, 1024 * 256); var X6 = (uint)random.Next(0, 1024 * 256); var X7 = (uint)random.Next(0, 1024 * 256); var X8 = (uint)random.Next(0, 1024 * 256); var X9 = (uint)random.Next(0, 1024 * 256); var elements = new RocketPack_IntElements(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9); elementsList.Add(elements); } _rocketPack_Message = new RocketPack_IntElementsList(elementsList.ToArray()); } } }
static BytesSerializeBenchmark() { { var random = new Random(0); var elementsList = new List <MessagePack_BytesElements>(); for (int i = 0; i < 10; i++) { var elements = new MessagePack_BytesElements() { X0 = new byte[random.Next(0, 1024 * 256)], X1 = new byte[random.Next(0, 1024 * 256)], X2 = new byte[random.Next(0, 1024 * 256)], X3 = new byte[random.Next(0, 1024 * 256)], X4 = new byte[random.Next(0, 1024 * 256)], X5 = new byte[random.Next(0, 1024 * 256)], X6 = new byte[random.Next(0, 1024 * 256)], X7 = new byte[random.Next(0, 1024 * 256)], X8 = new byte[random.Next(0, 1024 * 256)], X9 = new byte[random.Next(0, 1024 * 256)], }; elementsList.Add(elements); } _messagePack_Message = new MessagePack_BytesElementsList() { List = elementsList.ToArray() }; } { var random = new Random(0); var bytesPool = BytesPool.Shared; using (var bytesPipe = new BytesPipe(bytesPool)) { var elementsList = new List <RocketPack_BytesElements>(); for (int i = 0; i < 10; i++) { var X0 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X1 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X2 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X3 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X4 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X5 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X6 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X7 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X8 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X9 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var elements = new RocketPack_BytesElements(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9); elementsList.Add(elements); } _rocketPack_Message = new RocketPack_BytesElementsList(elementsList.ToArray()); } } }
static BytesDeserializeBenchmark() { { var random = new Random(0); var elementsList = new List <MessagePack_BytesElements>(); for (int i = 0; i < 10; i++) { var elements = new MessagePack_BytesElements() { X0 = new byte[random.Next(0, 1024 * 256)], X1 = new byte[random.Next(0, 1024 * 256)], X2 = new byte[random.Next(0, 1024 * 256)], X3 = new byte[random.Next(0, 1024 * 256)], X4 = new byte[random.Next(0, 1024 * 256)], X5 = new byte[random.Next(0, 1024 * 256)], X6 = new byte[random.Next(0, 1024 * 256)], X7 = new byte[random.Next(0, 1024 * 256)], X8 = new byte[random.Next(0, 1024 * 256)], X9 = new byte[random.Next(0, 1024 * 256)], }; elementsList.Add(elements); } _messagePack_Bytes = MessagePack.MessagePackSerializer.Serialize(new MessagePack_BytesElementsList() { List = elementsList.ToArray() }); } { var bytesPool = BytesPool.Shared; var random = new Random(0); using (var bytesPipe = new BytesPipe(bytesPool)) { var elementsList = new List <RocketPack_BytesElements>(); for (int i = 0; i < 10; i++) { var X0 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X1 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X2 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X3 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X4 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X5 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X6 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X7 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X8 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var X9 = bytesPool.Memory.Rent(random.Next(0, 1024 * 256)); var elements = new RocketPack_BytesElements(X0, X1, X2, X3, X4, X5, X6, X7, X8, X9); elementsList.Add(elements); } var message = new RocketPack_BytesElementsList(elementsList.ToArray()); message.Export(bytesPipe.Writer, BytesPool.Shared); _rocketPack_Bytes = new byte[bytesPipe.Writer.WrittenBytes]; bytesPipe.Reader.GetSequence().CopyTo(_rocketPack_Bytes); } } }