public class WebSocketConnectOptions extends RequestOptions
HttpClient
connect a WebSocket
.Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_ALLOW_ORIGIN_HEADER
The default WebSocket allow origin header =
true |
static ProxyOptions |
DEFAULT_PROXY_OPTIONS
The default value for proxy options =
null |
static boolean |
DEFAULT_REGISTER_WRITE_HANDLERS
Whether write-handlers should be registered by default = false.
|
static List<String> |
DEFAULT_SUB_PROTOCOLS
The default WebSocket sub protocols =
null |
static WebsocketVersion |
DEFAULT_VERSION
The default WebSocket version =
WebsocketVersion.V13 |
DEFAULT_FOLLOW_REDIRECTS, DEFAULT_HOST, DEFAULT_HTTP_METHOD, DEFAULT_PORT, DEFAULT_SERVER, DEFAULT_SSL, DEFAULT_TIMEOUT, DEFAULT_URI
Constructor and Description |
---|
WebSocketConnectOptions() |
WebSocketConnectOptions(JsonObject json) |
WebSocketConnectOptions(WebSocketConnectOptions other) |
Modifier and Type | Method and Description |
---|---|
WebSocketConnectOptions |
addHeader(CharSequence key,
CharSequence value)
Add a request header.
|
WebSocketConnectOptions |
addHeader(CharSequence key,
Iterable<CharSequence> values) |
WebSocketConnectOptions |
addHeader(String key,
String value)
Add a request header.
|
WebSocketConnectOptions |
addSubProtocol(String subprotocol)
Add a WebSocket sub protocol to use.
|
boolean |
getAllowOriginHeader() |
ProxyOptions |
getProxyOptions()
Get the proxy options override for connections
|
List<String> |
getSubProtocols() |
WebsocketVersion |
getVersion() |
boolean |
isRegisterWriteHandlers() |
WebSocketConnectOptions |
putHeader(CharSequence key,
CharSequence value)
Set a request header.
|
WebSocketConnectOptions |
putHeader(CharSequence key,
Iterable<CharSequence> values) |
WebSocketConnectOptions |
putHeader(String key,
String value)
Set a request header.
|
WebSocketConnectOptions |
setAllowOriginHeader(boolean allowOriginHeader)
Set whether to add the
origin header to the WebSocket handshake request, enabled by default. |
WebSocketConnectOptions |
setHeaders(MultiMap headers)
Set request headers from a multi-map.
|
WebSocketConnectOptions |
setHost(String host)
Set the host name to be used by the client request.
|
WebSocketConnectOptions |
setPort(Integer port)
Set the port to be used by the client request.
|
RequestOptions |
setProxyOptions(ProxyOptions proxyOptions)
Override the
HttpClientOptions.setProxyOptions(ProxyOptions) proxy options
for connections. |
WebSocketConnectOptions |
setRegisterWriteHandlers(boolean registerWriteHandlers)
Whether write-handlers should be registered on the
EventBus . |
WebSocketConnectOptions |
setSsl(Boolean ssl)
Set whether SSL/TLS is enabled.
|
WebSocketConnectOptions |
setSubProtocols(List<String> subProtocols)
Set the WebSocket sub protocols to use.
|
WebSocketConnectOptions |
setTimeout(long timeout)
Sets the amount of time after which if the WebSocket handshake does not happen within the timeout period an
WebSocketHandshakeException will be passed to the exception handler and the connection will be closed. |
WebSocketConnectOptions |
setURI(String uri)
Set the request relative URI.
|
WebSocketConnectOptions |
setVersion(WebsocketVersion version)
Set the WebSocket version.
|
JsonObject |
toJson() |
getFollowRedirects, getHeaders, getHost, getMethod, getPort, getServer, getTimeout, getTraceOperation, getURI, isSsl, removeHeader, removeHeader, setAbsoluteURI, setAbsoluteURI, setFollowRedirects, setMethod, setServer, setTraceOperation
public static final ProxyOptions DEFAULT_PROXY_OPTIONS
null
public static final WebsocketVersion DEFAULT_VERSION
WebsocketVersion.V13
public static final List<String> DEFAULT_SUB_PROTOCOLS
null
public static final boolean DEFAULT_ALLOW_ORIGIN_HEADER
true
public static final boolean DEFAULT_REGISTER_WRITE_HANDLERS
public WebSocketConnectOptions()
public WebSocketConnectOptions(WebSocketConnectOptions other)
public WebSocketConnectOptions(JsonObject json)
public WebsocketVersion getVersion()
public WebSocketConnectOptions setVersion(WebsocketVersion version)
public List<String> getSubProtocols()
null
if there are nonepublic WebSocketConnectOptions setSubProtocols(List<String> subProtocols)
public WebSocketConnectOptions addSubProtocol(String subprotocol)
public ProxyOptions getProxyOptions()
getProxyOptions
in class RequestOptions
public RequestOptions setProxyOptions(ProxyOptions proxyOptions)
HttpClientOptions.setProxyOptions(ProxyOptions)
proxy options
for connections.setProxyOptions
in class RequestOptions
proxyOptions
- proxy options override objectpublic boolean getAllowOriginHeader()
origin
header to the WebSocket handshake requestpublic WebSocketConnectOptions setAllowOriginHeader(boolean allowOriginHeader)
origin
header to the WebSocket handshake request, enabled by default.
Set to false
when a server does not accept WebSocket with an origin header.
allowOriginHeader
- whether to add the origin
header to the WebSocket handshake requestpublic WebSocketConnectOptions setHost(String host)
RequestOptions
setHost
in class RequestOptions
public WebSocketConnectOptions setPort(Integer port)
RequestOptions
setPort
in class RequestOptions
public WebSocketConnectOptions setSsl(Boolean ssl)
RequestOptions
setSsl
in class RequestOptions
ssl
- true if enabledpublic WebSocketConnectOptions setURI(String uri)
RequestOptions
setURI
in class RequestOptions
uri
- the relative uripublic WebSocketConnectOptions setTimeout(long timeout)
WebSocketHandshakeException
will be passed to the exception handler and the connection will be closed.setTimeout
in class RequestOptions
timeout
- the amount of time in milliseconds.public WebSocketConnectOptions addHeader(String key, String value)
RequestOptions
addHeader
in class RequestOptions
key
- the header keyvalue
- the header valuepublic WebSocketConnectOptions addHeader(CharSequence key, CharSequence value)
RequestOptions
addHeader
in class RequestOptions
key
- the header keyvalue
- the header valuepublic WebSocketConnectOptions addHeader(CharSequence key, Iterable<CharSequence> values)
addHeader
in class RequestOptions
public WebSocketConnectOptions putHeader(String key, String value)
RequestOptions
putHeader
in class RequestOptions
key
- the header keyvalue
- the header valuepublic WebSocketConnectOptions putHeader(CharSequence key, CharSequence value)
RequestOptions
putHeader
in class RequestOptions
key
- the header keyvalue
- the header valuepublic WebSocketConnectOptions putHeader(CharSequence key, Iterable<CharSequence> values)
putHeader
in class RequestOptions
public WebSocketConnectOptions setHeaders(MultiMap headers)
RequestOptions
setHeaders
in class RequestOptions
headers
- the headerspublic JsonObject toJson()
toJson
in class RequestOptions
public boolean isRegisterWriteHandlers()
true
if write-handlers should be registered on the EventBus
, otherwise false
public WebSocketConnectOptions setRegisterWriteHandlers(boolean registerWriteHandlers)
EventBus
.
Defaults to false
.
registerWriteHandlers
- true to register write-handlersWebSocketBase.textHandlerID()
,
WebSocketBase.binaryHandlerID()
Copyright © 2024 Eclipse. All rights reserved.