Class WebSocketClientProtocolConfig.Builder
- java.lang.Object
-
- io.netty.handler.codec.http.websocketx.WebSocketClientProtocolConfig.Builder
-
- Enclosing class:
- WebSocketClientProtocolConfig
public static final class WebSocketClientProtocolConfig.Builder extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
absoluteUpgradeUrl
private boolean
allowExtensions
private boolean
allowMaskMismatch
private HttpHeaders
customHeaders
private boolean
dropPongFrames
private long
forceCloseTimeoutMillis
private boolean
generateOriginHeader
private boolean
handleCloseFrames
private long
handshakeTimeoutMillis
private int
maxFramePayloadLength
private boolean
performMasking
private WebSocketCloseStatus
sendCloseFrame
private java.lang.String
subprotocol
private WebSocketVersion
version
private java.net.URI
webSocketUri
private boolean
withUTF8Validator
-
Constructor Summary
Constructors Modifier Constructor Description private
Builder(WebSocketClientProtocolConfig clientConfig)
private
Builder(java.net.URI webSocketUri, java.lang.String subprotocol, WebSocketVersion version, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength, boolean performMasking, boolean allowMaskMismatch, boolean handleCloseFrames, WebSocketCloseStatus sendCloseFrame, boolean dropPongFrames, long handshakeTimeoutMillis, long forceCloseTimeoutMillis, boolean absoluteUpgradeUrl, boolean generateOriginHeader, boolean withUTF8Validator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WebSocketClientProtocolConfig.Builder
absoluteUpgradeUrl(boolean absoluteUpgradeUrl)
Use an absolute url for the Upgrade request, typically when connecting through an HTTP proxy over clear HTTPWebSocketClientProtocolConfig.Builder
allowExtensions(boolean allowExtensions)
Allow extensions to be used in the reserved bits of the web socket frameWebSocketClientProtocolConfig.Builder
allowMaskMismatch(boolean allowMaskMismatch)
When set to true, frames which are not masked properly according to the standard will still be accepted.WebSocketClientProtocolConfig
build()
Build unmodifiable client protocol configuration.WebSocketClientProtocolConfig.Builder
customHeaders(HttpHeaders customHeaders)
Map of custom headers to add to the client requestWebSocketClientProtocolConfig.Builder
dropPongFrames(boolean dropPongFrames)
true
if pong frames should not be forwardedWebSocketClientProtocolConfig.Builder
forceCloseTimeoutMillis(long forceCloseTimeoutMillis)
Close the connection if it was not closed by the server after timeout specifiedWebSocketClientProtocolConfig.Builder
generateOriginHeader(boolean generateOriginHeader)
Allows to generate the `Origin`|`Sec-WebSocket-Origin` header value for handshake request according the given webSocketURI.WebSocketClientProtocolConfig.Builder
handleCloseFrames(boolean handleCloseFrames)
true
if close frames should not be forwarded and just close the channelWebSocketClientProtocolConfig.Builder
handshakeTimeoutMillis(long handshakeTimeoutMillis)
Handshake timeout in mills, when handshake timeout, will trigger user eventWebSocketClientProtocolHandler.ClientHandshakeStateEvent.HANDSHAKE_TIMEOUT
WebSocketClientProtocolConfig.Builder
maxFramePayloadLength(int maxFramePayloadLength)
Maximum length of a frame's payloadWebSocketClientProtocolConfig.Builder
performMasking(boolean performMasking)
Whether to mask all written websocket frames.WebSocketClientProtocolConfig.Builder
sendCloseFrame(WebSocketCloseStatus sendCloseFrame)
Close frame to send, when close frame was not send manually.WebSocketClientProtocolConfig.Builder
subprotocol(java.lang.String subprotocol)
Sub protocol request sent to the server.WebSocketClientProtocolConfig.Builder
version(WebSocketVersion version)
Version of web socket specification to use to connect to the serverWebSocketClientProtocolConfig.Builder
webSocketUri(java.lang.String webSocketUri)
URL for web socket communications.WebSocketClientProtocolConfig.Builder
webSocketUri(java.net.URI webSocketUri)
URL for web socket communications.WebSocketClientProtocolConfig.Builder
withUTF8Validator(boolean withUTF8Validator)
Toggles UTF8 validation for payload of text websocket frames.
-
-
-
Field Detail
-
webSocketUri
private java.net.URI webSocketUri
-
subprotocol
private java.lang.String subprotocol
-
version
private WebSocketVersion version
-
allowExtensions
private boolean allowExtensions
-
customHeaders
private HttpHeaders customHeaders
-
maxFramePayloadLength
private int maxFramePayloadLength
-
performMasking
private boolean performMasking
-
allowMaskMismatch
private boolean allowMaskMismatch
-
handleCloseFrames
private boolean handleCloseFrames
-
sendCloseFrame
private WebSocketCloseStatus sendCloseFrame
-
dropPongFrames
private boolean dropPongFrames
-
handshakeTimeoutMillis
private long handshakeTimeoutMillis
-
forceCloseTimeoutMillis
private long forceCloseTimeoutMillis
-
absoluteUpgradeUrl
private boolean absoluteUpgradeUrl
-
generateOriginHeader
private boolean generateOriginHeader
-
withUTF8Validator
private boolean withUTF8Validator
-
-
Constructor Detail
-
Builder
private Builder(WebSocketClientProtocolConfig clientConfig)
-
Builder
private Builder(java.net.URI webSocketUri, java.lang.String subprotocol, WebSocketVersion version, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength, boolean performMasking, boolean allowMaskMismatch, boolean handleCloseFrames, WebSocketCloseStatus sendCloseFrame, boolean dropPongFrames, long handshakeTimeoutMillis, long forceCloseTimeoutMillis, boolean absoluteUpgradeUrl, boolean generateOriginHeader, boolean withUTF8Validator)
-
-
Method Detail
-
webSocketUri
public WebSocketClientProtocolConfig.Builder webSocketUri(java.lang.String webSocketUri)
URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.
-
webSocketUri
public WebSocketClientProtocolConfig.Builder webSocketUri(java.net.URI webSocketUri)
URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.
-
subprotocol
public WebSocketClientProtocolConfig.Builder subprotocol(java.lang.String subprotocol)
Sub protocol request sent to the server.
-
version
public WebSocketClientProtocolConfig.Builder version(WebSocketVersion version)
Version of web socket specification to use to connect to the server
-
allowExtensions
public WebSocketClientProtocolConfig.Builder allowExtensions(boolean allowExtensions)
Allow extensions to be used in the reserved bits of the web socket frame
-
customHeaders
public WebSocketClientProtocolConfig.Builder customHeaders(HttpHeaders customHeaders)
Map of custom headers to add to the client request
-
maxFramePayloadLength
public WebSocketClientProtocolConfig.Builder maxFramePayloadLength(int maxFramePayloadLength)
Maximum length of a frame's payload
-
performMasking
public WebSocketClientProtocolConfig.Builder performMasking(boolean performMasking)
Whether to mask all written websocket frames. This must be set to true in order to be fully compatible with the websocket specifications. Client applications that communicate with a non-standard server which doesn't require masking might set this to false to achieve a higher performance.
-
allowMaskMismatch
public WebSocketClientProtocolConfig.Builder allowMaskMismatch(boolean allowMaskMismatch)
When set to true, frames which are not masked properly according to the standard will still be accepted.
-
handleCloseFrames
public WebSocketClientProtocolConfig.Builder handleCloseFrames(boolean handleCloseFrames)
true
if close frames should not be forwarded and just close the channel
-
sendCloseFrame
public WebSocketClientProtocolConfig.Builder sendCloseFrame(WebSocketCloseStatus sendCloseFrame)
Close frame to send, when close frame was not send manually. Ornull
to disable proper close.
-
dropPongFrames
public WebSocketClientProtocolConfig.Builder dropPongFrames(boolean dropPongFrames)
true
if pong frames should not be forwarded
-
handshakeTimeoutMillis
public WebSocketClientProtocolConfig.Builder handshakeTimeoutMillis(long handshakeTimeoutMillis)
Handshake timeout in mills, when handshake timeout, will trigger user eventWebSocketClientProtocolHandler.ClientHandshakeStateEvent.HANDSHAKE_TIMEOUT
-
forceCloseTimeoutMillis
public WebSocketClientProtocolConfig.Builder forceCloseTimeoutMillis(long forceCloseTimeoutMillis)
Close the connection if it was not closed by the server after timeout specified
-
absoluteUpgradeUrl
public WebSocketClientProtocolConfig.Builder absoluteUpgradeUrl(boolean absoluteUpgradeUrl)
Use an absolute url for the Upgrade request, typically when connecting through an HTTP proxy over clear HTTP
-
generateOriginHeader
public WebSocketClientProtocolConfig.Builder generateOriginHeader(boolean generateOriginHeader)
Allows to generate the `Origin`|`Sec-WebSocket-Origin` header value for handshake request according the given webSocketURI. Usually it's not necessary and can be disabled, but for backward compatibility is set totrue
as default.
-
withUTF8Validator
public WebSocketClientProtocolConfig.Builder withUTF8Validator(boolean withUTF8Validator)
Toggles UTF8 validation for payload of text websocket frames. By default validation is enabled.
-
build
public WebSocketClientProtocolConfig build()
Build unmodifiable client protocol configuration.
-
-