2018-11-20 17:51:25 -05:00
|
|
|
package flowcontrol
|
|
|
|
|
2019-01-17 09:33:18 -05:00
|
|
|
import "v2ray.com/core/external/github.com/lucas-clemente/quic-go/internal/protocol"
|
2018-11-20 17:51:25 -05:00
|
|
|
|
|
|
|
type flowController interface {
|
|
|
|
// for sending
|
|
|
|
SendWindowSize() protocol.ByteCount
|
|
|
|
UpdateSendWindow(protocol.ByteCount)
|
|
|
|
AddBytesSent(protocol.ByteCount)
|
|
|
|
// for receiving
|
|
|
|
AddBytesRead(protocol.ByteCount)
|
|
|
|
GetWindowUpdate() protocol.ByteCount // returns 0 if no update is necessary
|
|
|
|
MaybeQueueWindowUpdate() // queues a window update, if necessary
|
|
|
|
IsNewlyBlocked() (bool, protocol.ByteCount)
|
|
|
|
}
|
|
|
|
|
|
|
|
// A StreamFlowController is a flow controller for a QUIC stream.
|
|
|
|
type StreamFlowController interface {
|
|
|
|
flowController
|
|
|
|
// for receiving
|
|
|
|
// UpdateHighestReceived should be called when a new highest offset is received
|
2018-11-23 11:04:53 -05:00
|
|
|
// final has to be to true if this is the final offset of the stream, as contained in a STREAM frame with FIN bit, and the RESET_STREAM frame
|
2018-11-20 17:51:25 -05:00
|
|
|
UpdateHighestReceived(offset protocol.ByteCount, final bool) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// The ConnectionFlowController is the flow controller for the connection.
|
|
|
|
type ConnectionFlowController interface {
|
|
|
|
flowController
|
|
|
|
}
|
|
|
|
|
|
|
|
type connectionFlowControllerI interface {
|
|
|
|
ConnectionFlowController
|
|
|
|
// The following two methods are not supposed to be called from outside this packet, but are needed internally
|
|
|
|
// for sending
|
|
|
|
EnsureMinimumWindowSize(protocol.ByteCount)
|
|
|
|
// for receiving
|
|
|
|
IncrementHighestReceived(protocol.ByteCount) error
|
|
|
|
}
|