Package io.micronaut.websocket
Interface WebSocketClient
-
- All Superinterfaces:
java.lang.AutoCloseable
public interface WebSocketClient extends java.lang.AutoCloseableInterface that provides a way to connect a client over WebSocket.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSCHEME_WSConstant for HTTP scheme.static java.lang.StringSCHEME_WSSConstant for HTTPS scheme.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description voidclose()<T extends java.lang.AutoCloseable>
org.reactivestreams.Publisher<T>connect(java.lang.Class<T> clientEndpointType, io.micronaut.http.MutableHttpRequest<?> request)Connect the given client endpoint type to the URI over WebSocket.default <T extends java.lang.AutoCloseable>
org.reactivestreams.Publisher<T>connect(java.lang.Class<T> clientEndpointType, java.lang.String uri)Connect the given client endpoint type to the URI over WebSocket.default <T extends java.lang.AutoCloseable>
org.reactivestreams.Publisher<T>connect(java.lang.Class<T> clientEndpointType, java.net.URI uri)Connect the given client endpoint type to the URI over WebSocket.<T extends java.lang.AutoCloseable>
org.reactivestreams.Publisher<T>connect(java.lang.Class<T> clientEndpointType, java.util.Map<java.lang.String,java.lang.Object> parameters)Connect the given client endpoint type.static WebSocketClientcreate(java.net.URI uri)Create a newWebSocketClient.static WebSocketClientcreate(java.net.URI uri, io.micronaut.http.client.HttpClientConfiguration configuration)Create a newWebSocketClientwith the specified configuration.static WebSocketClientcreate(java.net.URL url)Deprecated.Usecreate(URI)insteadstatic WebSocketClientcreate(java.net.URL url, io.micronaut.http.client.HttpClientConfiguration configuration)Deprecated.Usecreate(URI, HttpClientConfiguration)instead
-
-
-
Field Detail
-
SCHEME_WS
static final java.lang.String SCHEME_WS
Constant for HTTP scheme.- See Also:
- Constant Field Values
-
SCHEME_WSS
static final java.lang.String SCHEME_WSS
Constant for HTTPS scheme.- See Also:
- Constant Field Values
-
-
Method Detail
-
connect
<T extends java.lang.AutoCloseable> org.reactivestreams.Publisher<T> connect(java.lang.Class<T> clientEndpointType, io.micronaut.http.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 withClientWebSocketrequest- The original request to establish the connection- Returns:
- A
Publisherthat emits theClientWebSocketinstance
-
connect
<T extends java.lang.AutoCloseable> org.reactivestreams.Publisher<T> connect(java.lang.Class<T> clientEndpointType, java.util.Map<java.lang.String,java.lang.Object> parameters)Connect the given client endpoint type. Unlikeconnect(Class, URI)this method will the value declared within theClientWebSocketas 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 withClientWebSocketparameters- The URI parameters for the endpoint- Returns:
- A
Publisherthat emits theClientWebSocketinstance
-
close
void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
connect
default <T extends java.lang.AutoCloseable> org.reactivestreams.Publisher<T> connect(java.lang.Class<T> clientEndpointType, java.lang.String uri)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 withClientWebSocketuri- The URI to connect over- Returns:
- A
Publisherthat emits theClientWebSocketinstance
-
connect
default <T extends java.lang.AutoCloseable> org.reactivestreams.Publisher<T> connect(java.lang.Class<T> clientEndpointType, java.net.URI uri)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 withClientWebSocketuri- The URI to connect over- Returns:
- A
Publisherthat emits theClientWebSocketinstance
-
create
@Deprecated @NonNull static WebSocketClient create(@Nullable java.net.URL url)
Deprecated.Usecreate(URI)insteadCreate a newWebSocketClient. Note that this method should only be used outside of the context of a Micronaut application. The returnedWebSocketClientis not subject to dependency injection. The creator is responsible for closing the client to avoid leaking connections. Within a Micronaut application useInjectto inject a client instead.- Parameters:
url- The base URL- Returns:
- The client
-
create
@Deprecated @NonNull static WebSocketClient create(@Nullable java.net.URL url, io.micronaut.http.client.HttpClientConfiguration configuration)
Deprecated.Usecreate(URI, HttpClientConfiguration)insteadCreate a newWebSocketClientwith the specified configuration. Note that this method should only be used outside of the context of an application. Within Micronaut useInjectto inject a client instead- Parameters:
url- The base URLconfiguration- the client configuration- Returns:
- The client
- Since:
- 2.2.0
-
create
@NonNull static WebSocketClient create(@Nullable java.net.URI uri)
Create a newWebSocketClient. Note that this method should only be used outside of the context of a Micronaut application. The returnedWebSocketClientis not subject to dependency injection. The creator is responsible for closing the client to avoid leaking connections. Within a Micronaut application useInjectto inject a client instead.- Parameters:
uri- The base URI- Returns:
- The client
- Since:
- 3.2.0
-
create
@NonNull static WebSocketClient create(@Nullable java.net.URI uri, io.micronaut.http.client.HttpClientConfiguration configuration)
Create a newWebSocketClientwith the specified configuration. Note that this method should only be used outside of the context of an application. Within Micronaut useInjectto inject a client instead- Parameters:
uri- The base URIconfiguration- the client configuration- Returns:
- The client
- Since:
- 3.2.0
-
-