Package io.micronaut.websocket
Interface WebSocketClient
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
DefaultHttpClient
Interface that provides a way to connect a client over WebSocket.
- Since:
- 1.0
- Author:
- graemerocher
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
<T extends AutoCloseable>
Publisher<T>connect
(Class<T> clientEndpointType, MutableHttpRequest<?> request) Connect the given client endpoint type to the URI over WebSocket.default <T extends AutoCloseable>
Publisher<T>Connect the given client endpoint type to the URI over WebSocket.default <T extends AutoCloseable>
Publisher<T>Connect the given client endpoint type to the URI over WebSocket.<T extends AutoCloseable>
Publisher<T>Connect the given client endpoint type.static @NonNull WebSocketClient
Create a newWebSocketClient
.static @NonNull WebSocketClient
create
(@Nullable URI uri, HttpClientConfiguration configuration) Create a newWebSocketClient
with the specified configuration.static @NonNull WebSocketClient
Deprecated.static @NonNull WebSocketClient
create
(@Nullable URL url, HttpClientConfiguration configuration) Deprecated.Usecreate(URI, HttpClientConfiguration)
instead
-
Field Details
-
SCHEME_WS
Constant for HTTP scheme.- See Also:
-
SCHEME_WSS
Constant for HTTPS scheme.- See Also:
-
-
Method Details
-
connect
<T extends AutoCloseable> Publisher<T> connect(Class<T> clientEndpointType, MutableHttpRequest<?> request) Connect the given client endpoint type to the URI over WebSocket.- Type Parameters:
T
- The generic type- Parameters:
clientEndpointType
- The endpoint type. Should be a class annotated withClientWebSocket
request
- The original request to establish the connection- Returns:
- A
Publisher
that emits theClientWebSocket
instance
-
connect
<T extends AutoCloseable> Publisher<T> connect(Class<T> clientEndpointType, Map<String, Object> parameters) Connect the given client endpoint type. Unlikeconnect(Class, URI)
this method will the value declared within theClientWebSocket
as the URI and expand the URI with the given parameters.- Type Parameters:
T
- The generic type- Parameters:
clientEndpointType
- The endpoint type. Should be a class annotated withClientWebSocket
parameters
- The URI parameters for the endpoint- Returns:
- A
Publisher
that emits theClientWebSocket
instance
-
close
void close()- Specified by:
close
in interfaceAutoCloseable
-
connect
Connect the given client endpoint type to the URI over WebSocket.- Type Parameters:
T
- The generic type- Parameters:
clientEndpointType
- The endpoint type. Should be a class annotated withClientWebSocket
uri
- The URI to connect over- Returns:
- A
Publisher
that emits theClientWebSocket
instance
-
connect
Connect the given client endpoint type to the URI over WebSocket.- Type Parameters:
T
- The generic type- Parameters:
clientEndpointType
- The endpoint type. Should be a class annotated withClientWebSocket
uri
- The URI to connect over- Returns:
- A
Publisher
that emits theClientWebSocket
instance
-
create
Deprecated.Usecreate(URI)
insteadCreate a newWebSocketClient
. Note that this method should only be used outside of the context of a Micronaut application. The returnedWebSocketClient
is not subject to dependency injection. The creator is responsible for closing the client to avoid leaking connections. Within a Micronaut application useInject
to inject a client instead.- Parameters:
url
- The base URL- Returns:
- The client
-
create
@Deprecated @NonNull static @NonNull WebSocketClient create(@Nullable @Nullable URL url, HttpClientConfiguration configuration) Deprecated.Usecreate(URI, HttpClientConfiguration)
insteadCreate a newWebSocketClient
with the specified configuration. Note that this method should only be used outside of the context of an application. Within Micronaut useInject
to inject a client instead- Parameters:
url
- The base URLconfiguration
- the client configuration- Returns:
- The client
- Since:
- 2.2.0
-
create
Create a newWebSocketClient
. Note that this method should only be used outside of the context of a Micronaut application. The returnedWebSocketClient
is not subject to dependency injection. The creator is responsible for closing the client to avoid leaking connections. Within a Micronaut application useInject
to inject a client instead.- Parameters:
uri
- The base URI- Returns:
- The client
- Since:
- 3.2.0
-
create
@NonNull static @NonNull WebSocketClient create(@Nullable @Nullable URI uri, HttpClientConfiguration configuration) Create a newWebSocketClient
with the specified configuration. Note that this method should only be used outside of the context of an application. Within Micronaut useInject
to inject a client instead- Parameters:
uri
- The base URIconfiguration
- the client configuration- Returns:
- The client
- Since:
- 3.2.0
-
create(URI)
instead