Transparently encodes a single frame.

At construction, the BOF is first appended to the WriteBuffer object passed to FramingStream.CreateAsync. Afterwards, when data is written to this stream then it is first encoded and the encoded form is then appended to the WriteBuffer object.

Caution: DisposeAsync must be called in the end.

Inheritance: BufferStream
コード例 #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);
        }
コード例 #2
0
 private MessageEncodingStream(S101Message message, WriteBuffer rawBuffer, FramingStream framingStream)
 {
     this.unframedBuffer = new WriteBuffer(this.WriteUnframedAsync, Constants.MessageHeaderMaxLength);
     this.message        = message;
     this.rawBuffer      = rawBuffer;
     this.framingStream  = framingStream;
 }
コード例 #3
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);
        }
コード例 #4
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);
 }
コード例 #5
0
 private MessageEncodingStream(S101Message message, WriteBuffer rawBuffer, FramingStream framingStream)
 {
     this.unframedBuffer = new WriteBuffer(this.WriteUnframedAsync, Constants.MessageHeaderMaxLength);
     this.message = message;
     this.rawBuffer = rawBuffer;
     this.framingStream = framingStream;
 }