Top Description Methods
io.vertx.core.http

public Interface WebSocketClient

extends Measured
Known Direct Implementers
io.vertx.core.http.impl.SharedWebSocketClient, io.vertx.core.http.impl.WebSocketClientImpl
Annotations
@VertxGen
Imports
io.vertx.codegen.annotations.VertxGen, io.vertx.core.AsyncResult, .Future, .Handler, io.vertx.core.metrics.Measured, io.vertx.core.net.SSLOptions

An asynchronous WebSocket client.

It allows you to open WebSockets to servers.

Author
Tim Fox

Method Summary

Modifier and TypeMethod and Description
public void
close(Handler<AsyncResult<Void>> handler)

Close the client.

public Future<Void>
close()

Like close(Handler) but returns a Future of the asynchronous result

public default void
connect(int
the port
port
,
String
the host
host
,
String
the relative URI
requestURI
,
Handler<AsyncResult<WebSocket>>
handler that will be called with the WebSocket when connected
handler
)

Connect a WebSocket to the specified port, host and relative request URI

public default Future<WebSocket>
connect(int port, String host, String requestURI)

Like connect(int, String, String, Handler) but returns a Future of the asynchronous result

public default void
connect(String
the host
host
,
String
the relative URI
requestURI
,
Handler<AsyncResult<WebSocket>>
handler that will be called with the WebSocket when connected
handler
)

Connect a WebSocket to the default client port and specified host and relative request URI.

public default Future<WebSocket>
connect(String host, String requestURI)

Like connect(String, String, Handler) but returns a Future of the asynchronous result

public default void
connect(String
the relative URI
requestURI
,
Handler<AsyncResult<WebSocket>>
handler that will be called with the WebSocket when connected
handler
)

Connect a WebSocket to the default client port, default client host and specified, relative request URI.

public default Future<WebSocket>
connect(String requestURI)

Like connect(String, Handler) but returns a Future of the asynchronous result

public void
connect(WebSocketConnectOptions
the request options
options
,
Handler<AsyncResult<WebSocket>> handler)

Connect a WebSocket with the specified options.

public Future<WebSocket>
connect(WebSocketConnectOptions options)

Like connect(WebSocketConnectOptions, Handler) but returns a Future of the asynchronous result

public default Future<Boolean>

Returns:

a future signaling the update success
updateSSLOptions
(SSLOptions
the new SSL options
options
)

Update the client with new SSL options, the update happens if the options object is valid and different from the existing options object.

public default void
updateSSLOptions(SSLOptions
the new SSL options
options
,
Handler<AsyncResult<Boolean>>
the update handler
handler
)

Like updateSSLOptions(SSLOptions) but supplying a handler that will be called when the update happened (or has failed).

public Future<Boolean>

Returns:

a future signaling the update success
updateSSLOptions
(SSLOptions
the new SSL options
options
,
boolean
force the update when options are equals
force
)

Update the client with new SSL options, the update happens if the options object is valid and different from the existing options object.

public default void
updateSSLOptions(SSLOptions
the new SSL options
options
,
boolean
force the update when options are equals
force
,
Handler<AsyncResult<Boolean>>
the update handler
handler
)

Like updateSSLOptions(SSLOptions) but supplying a handler that will be called when the update happened (or has failed).

public ClientWebSocket

Returns:

the client WebSocket
webSocket
()

Create a WebSocket that is not yet connected to the server.

Inherited from io.vertx.core.metrics.Measured:
isMetricsEnabled

Method Detail

closeback to summary
public void close(Handler<AsyncResult<Void>> handler)

Close the client. Closing will close down any pooled connections. Clients should always be closed after use.

closeback to summary
public Future<Void> close()

Like close(Handler) but returns a Future of the asynchronous result

connectback to summary
public default void connect(int port, String host, String requestURI, Handler<AsyncResult<WebSocket>> handler)

Connect a WebSocket to the specified port, host and relative request URI

Parameters
port:int

the port

host:String

the host

requestURI:String

the relative URI

handler:Handler<AsyncResult<WebSocket>>

handler that will be called with the WebSocket when connected

connectback to summary
public default Future<WebSocket> connect(int port, String host, String requestURI)

Like connect(int, String, String, Handler) but returns a Future of the asynchronous result

connectback to summary
public default void connect(String host, String requestURI, Handler<AsyncResult<WebSocket>> handler)

Connect a WebSocket to the default client port and specified host and relative request URI.

Parameters
host:String

the host

requestURI:String

the relative URI

handler:Handler<AsyncResult<WebSocket>>

handler that will be called with the WebSocket when connected

connectback to summary
public default Future<WebSocket> connect(String host, String requestURI)

Like connect(String, String, Handler) but returns a Future of the asynchronous result

connectback to summary
public default void connect(String requestURI, Handler<AsyncResult<WebSocket>> handler)

Connect a WebSocket to the default client port, default client host and specified, relative request URI.

Parameters
requestURI:String

the relative URI

handler:Handler<AsyncResult<WebSocket>>

handler that will be called with the WebSocket when connected

connectback to summary
public default Future<WebSocket> connect(String requestURI)

Like connect(String, Handler) but returns a Future of the asynchronous result

connectback to summary
public void connect(WebSocketConnectOptions options, Handler<AsyncResult<WebSocket>> handler)

Connect a WebSocket with the specified options.

Parameters
options:WebSocketConnectOptions

the request options

connectback to summary
public Future<WebSocket> connect(WebSocketConnectOptions options)

Like connect(WebSocketConnectOptions, Handler) but returns a Future of the asynchronous result

updateSSLOptionsback to summary
public default Future<Boolean> updateSSLOptions(SSLOptions options)

Update the client with new SSL options, the update happens if the options object is valid and different from the existing options object.

Parameters
options:SSLOptions

the new SSL options

Returns:Future<Boolean>

a future signaling the update success

updateSSLOptionsback to summary
public default void updateSSLOptions(SSLOptions options, Handler<AsyncResult<Boolean>> handler)

Like updateSSLOptions(SSLOptions) but supplying a handler that will be called when the update happened (or has failed).

Parameters
options:SSLOptions

the new SSL options

handler:Handler<AsyncResult<Boolean>>

the update handler

updateSSLOptionsback to summary
public Future<Boolean> updateSSLOptions(SSLOptions options, boolean force)

Update the client with new SSL options, the update happens if the options object is valid and different from the existing options object.

The options object is compared using its equals method against the existing options to prevent an update when the objects are equals since loading options can be costly, this can happen for share TCP servers. When object are equals, setting force to true forces the update.

Parameters
options:SSLOptions

the new SSL options

force:boolean

force the update when options are equals

Returns:Future<Boolean>

a future signaling the update success

updateSSLOptionsback to summary
public default void updateSSLOptions(SSLOptions options, boolean force, Handler<AsyncResult<Boolean>> handler)

Like updateSSLOptions(SSLOptions) but supplying a handler that will be called when the update happened (or has failed).

Parameters
options:SSLOptions

the new SSL options

force:boolean

force the update when options are equals

handler:Handler<AsyncResult<Boolean>>

the update handler

webSocketback to summary
public ClientWebSocket webSocket()

Create a WebSocket that is not yet connected to the server.

Returns:ClientWebSocket

the client WebSocket