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 WebSocketClientConnectionSet the path param.
-
Method Details
-
baseUri
Set the base URI.- Parameters:
baseUri-- Returns:
- self
-
baseUri
Set the base URI.- Parameters:
baseUri-- Returns:
- self
-
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
-
connect
- Returns:
- a new
Uniwith aWebSocketClientConnectionitem
-
connectAndAwait
- Returns:
- the client connection
-