CreateAsync() static private method

static private CreateAsync ( WriteBuffer writeBuffer, CancellationToken cancellationToken ) : Task
writeBuffer WriteBuffer
cancellationToken System.Threading.CancellationToken
return Task
Esempio n. 1
0
        private async Task CreateFramingStream(PacketFlags packetFlags, CancellationToken cancellationToken)
        {
            this.framingStream = await FramingStream.CreateAsync(this.rawBuffer, cancellationToken);

            this.message.PacketFlags = packetFlags;
            await this.message.WriteToAsync(this.unframedBuffer, cancellationToken);
        }
Esempio n. 2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        internal static async Task <MessageEncodingStream> CreateAsync(
            WriteBuffer rawBuffer, S101Message message, CancellationToken cancellationToken)
        {
            message.PacketFlags =
                PacketFlags.FirstPacket | (message.CanHaveMultiplePackets ? PacketFlags.None : PacketFlags.LastPacket);
            var framingStream = await FramingStream.CreateAsync(rawBuffer, cancellationToken);

            var result = new MessageEncodingStream(message, rawBuffer, framingStream);
            await message.WriteToAsync(result.unframedBuffer, cancellationToken);

            return(result);
        }