Package org.omegazero.http.h2.streams
Class ControlStream
java.lang.Object
org.omegazero.http.h2.streams.HTTP2Stream
org.omegazero.http.h2.streams.ControlStream
Represents the connection
HTTP2Stream
where frames are exchanged that affect the entire HTTP/2 connection (stream with ID equal to 0).- Since:
- 1.2.1
-
Field Summary
Fields inherited from class org.omegazero.http.h2.streams.HTTP2Stream
connection, localWindowSize, receiverWindowSize, streamId, windowSizeLock
-
Constructor Summary
ConstructorsConstructorDescriptionControlStream
(WritableSocket connection, HTTP2Settings localSettings) Creates aControlStream
instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
consumeLocalConnectionWindow
(int size) Reduces the local connection window by the given size because a flow-controlled packet was received.void
consumeReceiverConnectionWindow
(int size) Reduces the remote's connection window by the given size because a flow-controlled packet is being sent.Returns the localHTTP2Settings
.int
Returns the connection window size of the local endpoint.int
Returns the connection window size of the remote endpoint.Returns theHTTP2Settings
sent by the remote endpoint.boolean
Returnstrue
if a SETTINGS frame was received.void
receiveFrame
(int type, int flags, byte[] data) This method is called if a frame is received on this HTTP/2 stream.void
sendGoaway
(int highestStreamId, int errorCode) Sends a GOAWAY frame with the given stream ID and error code on this control stream.void
setOnSettingsUpdate
(Consumer<HTTP2Settings> onSettingsUpdate) Sets the callback that is called when a SETTINGS frame is received from the remote endpoint.void
setOnWindowUpdate
(Runnable onWindowUpdate) Sets the callback that is called when a WINDOW_UPDATE frame is received from the remote endpoint.protected void
This method is called when a window update frame is received.void
writeSettings
(HTTP2Settings settings) Sends a SETTINGS frame with the givenHTTP2Settings
data on this control stream.void
writeSettings
(HTTP2Settings settings, int... settingIds) Sends a SETTINGS frame with the givenHTTP2Settings
data on this control stream.Methods inherited from class org.omegazero.http.h2.streams.HTTP2Stream
getConnection, getStreamId, isFlowControlledFrameType, sendWindowSizeUpdate, writeFrame, writeFrame, writeFrame
-
Constructor Details
-
ControlStream
Creates aControlStream
instance.- Parameters:
connection
- The underlying connectionlocalSettings
- The localHTTP2Settings
-
-
Method Details
-
sendGoaway
public void sendGoaway(int highestStreamId, int errorCode) Sends a GOAWAY frame with the given stream ID and error code on this control stream.- Parameters:
highestStreamId
- The last processed stream IDerrorCode
- The error code
-
writeSettings
Sends a SETTINGS frame with the givenHTTP2Settings
data on this control stream.This method send all setting values that differ from the default value.
- Parameters:
settings
- The settings- See Also:
-
writeSettings
Sends a SETTINGS frame with the givenHTTP2Settings
data on this control stream.This method send all settings with an ID in settingIds.
- Parameters:
settings
- The settingssettingIds
- The IDs of the settings to send- See Also:
-
receiveFrame
Description copied from class:HTTP2Stream
This method is called if a frame is received on this HTTP/2 stream.- Overrides:
receiveFrame
in classHTTP2Stream
- Parameters:
type
- The frame type numberflags
- The frame flagsdata
- The frame payload- Throws:
HTTP2ConnectionError
- If a HTTP/2 connection error occurs, for example because the frame payload is invalid
-
windowUpdate
protected void windowUpdate()Description copied from class:HTTP2Stream
This method is called when a window update frame is received. TheHTTP2Stream.receiverWindowSize
is updated before this method is called.- Overrides:
windowUpdate
in classHTTP2Stream
-
setOnSettingsUpdate
Sets the callback that is called when a SETTINGS frame is received from the remote endpoint.- Parameters:
onSettingsUpdate
- The callback
-
setOnWindowUpdate
Sets the callback that is called when a WINDOW_UPDATE frame is received from the remote endpoint.- Parameters:
onWindowUpdate
- The callback
-
isSettingsReceived
public boolean isSettingsReceived()Returnstrue
if a SETTINGS frame was received.- Returns:
true
if a SETTINGS frame was received
-
getLocalSettings
Returns the localHTTP2Settings
.- Returns:
- The local
HTTP2Settings
-
getRemoteSettings
Returns theHTTP2Settings
sent by the remote endpoint.- Returns:
- The remote
HTTP2Settings
-
getReceiverWindowSize
public int getReceiverWindowSize()Returns the connection window size of the remote endpoint.- Returns:
- The remote connection window size
-
getLocalWindowSize
public int getLocalWindowSize()Returns the connection window size of the local endpoint.- Returns:
- The local connection window size
-
consumeReceiverConnectionWindow
public void consumeReceiverConnectionWindow(int size) Reduces the remote's connection window by the given size because a flow-controlled packet is being sent.- Parameters:
size
- The size of the payload of the flow-controlled packet
-
consumeLocalConnectionWindow
public void consumeLocalConnectionWindow(int size) Reduces the local connection window by the given size because a flow-controlled packet was received.- Parameters:
size
- The size of the payload of the flow-controlled packet
-