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_CONNECT_TIMEOUT, DEFAULT_FOLLOW_REDIRECTS, DEFAULT_HOST, DEFAULT_HTTP_METHOD, DEFAULT_IDLE_TIMEOUT, 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 |
setAbsoluteURI(String absoluteURI)
Parse an absolute URI to use, this will update the
ssl , host ,
port and uri fields. |
WebSocketConnectOptions |
setAbsoluteURI(URL url)
Like
RequestOptions.setAbsoluteURI(String) but using an URL parameter. |
WebSocketConnectOptions |
setAllowOriginHeader(boolean allowOriginHeader)
Set whether to add the
origin header to the WebSocket handshake request, enabled by default. |
WebSocketConnectOptions |
setConnectTimeout(long timeout)
Sets the amount of time after which, if the request is not obtained from the client within the timeout period,
the
Future<HttpClientRequest> obtained from the client is failed with a TimeoutException . |
WebSocketConnectOptions |
setFollowRedirects(Boolean followRedirects)
Set whether to follow HTTP redirect
|
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 |
setIdleTimeout(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 |
setMethod(HttpMethod method)
Set the HTTP method 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 |
setServer(SocketAddress server)
Set the server address to be used by the client request.
|
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 |
setTraceOperation(String op)
Override the operation the tracer use for this request.
|
WebSocketConnectOptions |
setURI(String uri)
Set the request relative URI.
|
WebSocketConnectOptions |
setVersion(WebsocketVersion version)
Set the WebSocket version.
|
JsonObject |
toJson() |
getConnectTimeout, getFollowRedirects, getHeaders, getHost, getIdleTimeout, getMethod, getPort, getServer, getTimeout, getTraceOperation, getURI, isSsl, removeHeader, removeHeader
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 setConnectTimeout(long timeout)
RequestOptions
Future<HttpClientRequest>
obtained from the client is failed with a TimeoutException
.
Note this is not related to the TCP HttpClientOptions.setConnectTimeout(int)
option, when a request is made against
a pooled HTTP client, the timeout applies to the duration to obtain a connection from the pool to serve the request, the timeout
might fire because the server does not respond in time or the pool is too busy to serve a request.setConnectTimeout
in class RequestOptions
timeout
- the amount of time in milliseconds.public WebSocketConnectOptions setIdleTimeout(long timeout)
WebSocketHandshakeException
will be passed to the exception handler and the connection will be closed.setIdleTimeout
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 WebSocketConnectOptions setServer(SocketAddress server)
RequestOptions
When the server address is null
, the address will be resolved after the host
property by the Vert.x resolver.
Use this when you want to connect to a specific server address without name resolution.
setServer
in class RequestOptions
public WebSocketConnectOptions setMethod(HttpMethod method)
RequestOptions
setMethod
in class RequestOptions
public WebSocketConnectOptions setFollowRedirects(Boolean followRedirects)
RequestOptions
setFollowRedirects
in class RequestOptions
followRedirects
- whether to follow redirectpublic WebSocketConnectOptions setAbsoluteURI(String absoluteURI)
RequestOptions
ssl
, host
,
port
and uri
fields.setAbsoluteURI
in class RequestOptions
absoluteURI
- the uri to usepublic WebSocketConnectOptions setAbsoluteURI(URL url)
RequestOptions
RequestOptions.setAbsoluteURI(String)
but using an URL
parameter.setAbsoluteURI
in class RequestOptions
url
- the uri to usepublic WebSocketConnectOptions setTraceOperation(String op)
RequestOptions
setTraceOperation
in class RequestOptions
op
- the overridepublic 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.