Interface WebSocketConnector<CLIENT>
- Type Parameters:
CLIENT- The client endpoint class
- All Known Implementing Classes:
WebSocketConnectorImpl
Quarkus provides a CDI bean with bean type WebSocketConnector<CLIENT> and qualifier Default. The actual type
argument of an injection point is used to determine the client endpoint. The type is validated during build
and if it does not represent a client endpoint then the build fails.
This construct is not thread-safe and should not be used concurrently.
Connectors should not be reused. If you need to create multiple connections in a row you'll need to obtain a new connetor
instance programmatically using Provider.get():
import jakarta.enterprise.inject.Instance;
@Inject
Instance<WebSocketConnector<MyEndpoint>> connector;
void connect() {
var connection1 = connector.get().baseUri(uri)
.addHeader("Foo", "alpha")
.connectAndAwait();
var connection2 = connector.get().baseUri(uri)
.addHeader("Foo", "bravo")
.connectAndAwait();
}
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionAdd a header used during the initial handshake request.addSubprotocol(String value) Add the subprotocol.default WebSocketConnector<CLIENT> Set the base URI.Set the base URI.io.smallrye.mutiny.Uni<WebSocketClientConnection> connect()default WebSocketClientConnectioncustomizeOptions(BiConsumer<io.vertx.core.http.WebSocketConnectOptions, io.vertx.core.http.WebSocketClientOptions> customizer) This method allows to customizeWebSocketConnectOptionsandWebSocketClientOptions.Set the path param.tlsConfigurationName(String tlsConfigurationName) Set the name of theTlsConfiguration.<VALUE> WebSocketConnector<CLIENT> userData(UserData.TypedKey<VALUE> key, VALUE value) Add a value to the connection user data.
-
Method Details
-
baseUri
Set the base URI.- Parameters:
baseUri-- Returns:
- self
-
baseUri
Set the base URI.- Parameters:
baseUri-- Returns:
- self
-
tlsConfigurationName
Set the name of theTlsConfiguration.- Parameters:
tlsConfigurationName-- Returns:
- self
- See Also:
-
pathParam
Set the path param.The value is encoded using
URLEncoder.encode(String, java.nio.charset.Charset)before it's used to build the target URI.- Parameters:
name-value-- Returns:
- self
- Throws:
IllegalArgumentException- If the client endpoint path does not contain a parameter with the given name- See Also:
-
addHeader
Add a header used during the initial handshake request.- Parameters:
name-value-- Returns:
- self
- See Also:
-
addSubprotocol
Add the subprotocol.- Parameters:
value-name-- Returns:
- self
-
userData
Add a value to the connection user data.- Type Parameters:
VALUE-- Parameters:
key-value-- Returns:
- self
- See Also:
-
connect
- Returns:
- a new
Uniwith aWebSocketClientConnectionitem
-
connectAndAwait
- Returns:
- the client connection
-
customizeOptions
WebSocketConnector<CLIENT> customizeOptions(BiConsumer<io.vertx.core.http.WebSocketConnectOptions, io.vertx.core.http.WebSocketClientOptions> customizer) This method allows to customizeWebSocketConnectOptionsandWebSocketClientOptions. Connection options configured directly with this API, such as host and port, have higher priority than this customizer. Client options configured directly with Quarkus configuration (e.g. if you configure the maximum size of a frame) have also higher priority than this customizer. Purpose of this customizer is to complement configuration options not configured elsewhere.- Parameters:
customizer- options customizer; must not be null- Returns:
- self
-