Interface WebSocketClient

  • All Superinterfaces:
    java.lang.AutoCloseable

    public interface WebSocketClient
    extends java.lang.AutoCloseable
    Interface that provides a way to connect a client over WebSocket.
    Since:
    1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String SCHEME_WS
      Constant for HTTP scheme.
      static java.lang.String SCHEME_WSS
      Constant for HTTPS scheme.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods 
      Modifier and Type Method Description
      void close()  
      <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 WebSocketClient create​(java.net.URI uri)
      Create a new WebSocketClient.
      static WebSocketClient create​(java.net.URI uri, io.micronaut.http.client.HttpClientConfiguration configuration)
      Create a new WebSocketClient with the specified configuration.
      static WebSocketClient create​(java.net.URL url)
      Deprecated.
      Use create(URI) instead
      static WebSocketClient create​(java.net.URL url, io.micronaut.http.client.HttpClientConfiguration configuration)
      Deprecated.
    • 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 with ClientWebSocket
        request - The original request to establish the connection
        Returns:
        A Publisher that emits the ClientWebSocket instance
      • 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. Unlike connect(Class, URI) this method will the value declared within the ClientWebSocket 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 with ClientWebSocket
        parameters - The URI parameters for the endpoint
        Returns:
        A Publisher that emits the ClientWebSocket instance
      • close

        void close()
        Specified by:
        close in interface java.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 with ClientWebSocket
        uri - The URI to connect over
        Returns:
        A Publisher that emits the ClientWebSocket instance
      • 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 with ClientWebSocket
        uri - The URI to connect over
        Returns:
        A Publisher that emits the ClientWebSocket instance
      • create

        @Deprecated
        @NonNull
        static WebSocketClient create​(@Nullable
                                      java.net.URL url)
        Deprecated.
        Use create(URI) instead
        Create a new WebSocketClient. Note that this method should only be used outside of the context of a Micronaut application. The returned WebSocketClient is not subject to dependency injection. The creator is responsible for closing the client to avoid leaking connections. Within a Micronaut application use Inject to 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.
        Create a new WebSocketClient with the specified configuration. Note that this method should only be used outside of the context of an application. Within Micronaut use Inject to inject a client instead
        Parameters:
        url - The base URL
        configuration - the client configuration
        Returns:
        The client
        Since:
        2.2.0
      • create

        @NonNull
        static WebSocketClient create​(@Nullable
                                      java.net.URI uri)
        Create a new WebSocketClient. Note that this method should only be used outside of the context of a Micronaut application. The returned WebSocketClient is not subject to dependency injection. The creator is responsible for closing the client to avoid leaking connections. Within a Micronaut application use Inject to 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 new WebSocketClient with the specified configuration. Note that this method should only be used outside of the context of an application. Within Micronaut use Inject to inject a client instead
        Parameters:
        uri - The base URI
        configuration - the client configuration
        Returns:
        The client
        Since:
        3.2.0