diff --git a/QuicNet.Infrastructure/PacketProcessing/PacketCreator.cs b/QuicNet.Infrastructure/PacketProcessing/PacketCreator.cs index cb4b9d5..b5cfbea 100644 --- a/QuicNet.Infrastructure/PacketProcessing/PacketCreator.cs +++ b/QuicNet.Infrastructure/PacketProcessing/PacketCreator.cs @@ -34,12 +34,12 @@ public ShortHeaderPacket CreateConnectionClosePacket(ErrorCode code, string reas return packet; } - public ShortHeaderPacket CreateDataPacket(UInt64 streamId, byte[] data) + public ShortHeaderPacket CreateDataPacket(UInt64 streamId, byte[] data, UInt64 offset) { ShortHeaderPacket packet = new ShortHeaderPacket(); packet.PacketNumber = _ns.Get(); packet.DestinationConnectionId = (byte)_peerConnectionId; - packet.AttachFrame(new StreamFrame(streamId, data, 0, true)); + packet.AttachFrame(new StreamFrame(streamId, data, offset, true)); return packet; } diff --git a/QuicNet/Streams/QuicStream.cs b/QuicNet/Streams/QuicStream.cs index 7dbfe09..f882ef8 100644 --- a/QuicNet/Streams/QuicStream.cs +++ b/QuicNet/Streams/QuicStream.cs @@ -21,6 +21,7 @@ public class QuicStream private QuicConnection _connection; private UInt64 _maximumStreamData; private UInt64 _currentTransferRate; + private UInt64 _sendOffset; public StreamState State { get; set; } public StreamType Type { get; set; } @@ -41,6 +42,7 @@ public QuicStream(QuicConnection connection, StreamId streamId) _maximumStreamData = QuicSettings.MaxStreamData; _currentTransferRate = 0; + _sendOffset = 0; _connection = connection; } @@ -52,10 +54,12 @@ public bool Send(byte[] data) _connection.IncrementRate(data.Length); - ShortHeaderPacket packet = _connection.PacketCreator.CreateDataPacket(this.StreamId.IntegerValue, data); + ShortHeaderPacket packet = _connection.PacketCreator.CreateDataPacket(this.StreamId.IntegerValue, data, _sendOffset); if (_connection.MaximumReached()) packet.AttachFrame(new StreamDataBlockedFrame(StreamId.IntegerValue, (UInt64)data.Length)); + _sendOffset += (UInt64)data.Length; + return _connection.SendData(packet); }