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 aControlStreaminstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidconsumeLocalConnectionWindow(int size) Reduces the local connection window by the given size because a flow-controlled packet was received.voidconsumeReceiverConnectionWindow(int size) Reduces the remote's connection window by the given size because a flow-controlled packet is being sent.Returns the localHTTP2Settings.intReturns the connection window size of the local endpoint.intReturns the connection window size of the remote endpoint.Returns theHTTP2Settingssent by the remote endpoint.booleanReturnstrueif a SETTINGS frame was received.voidreceiveFrame(int type, int flags, byte[] data) This method is called if a frame is received on this HTTP/2 stream.voidsendGoaway(int highestStreamId, int errorCode) Sends a GOAWAY frame with the given stream ID and error code on this control stream.voidsetOnSettingsUpdate(Consumer<HTTP2Settings> onSettingsUpdate) Sets the callback that is called when a SETTINGS frame is received from the remote endpoint.voidsetOnWindowUpdate(Runnable onWindowUpdate) Sets the callback that is called when a WINDOW_UPDATE frame is received from the remote endpoint.protected voidThis method is called when a window update frame is received.voidwriteSettings(HTTP2Settings settings) Sends a SETTINGS frame with the givenHTTP2Settingsdata on this control stream.voidwriteSettings(HTTP2Settings settings, int... settingIds) Sends a SETTINGS frame with the givenHTTP2Settingsdata 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 aControlStreaminstance.- 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 givenHTTP2Settingsdata 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 givenHTTP2Settingsdata 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:HTTP2StreamThis method is called if a frame is received on this HTTP/2 stream.- Overrides:
receiveFramein 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:HTTP2StreamThis method is called when a window update frame is received. TheHTTP2Stream.receiverWindowSizeis updated before this method is called.- Overrides:
windowUpdatein 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()Returnstrueif a SETTINGS frame was received.- Returns:
trueif a SETTINGS frame was received
-
getLocalSettings
Returns the localHTTP2Settings.- Returns:
- The local
HTTP2Settings
-
getRemoteSettings
Returns theHTTP2Settingssent 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
-