Interface ClientService


  • @DoNotImplement
    public interface ClientService
    Through this client service an extension can query details about connected or disconnected clients (with a persistent session) from the HiveMQ core.
    Since:
    4.0.0
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      @NotNull java.util.concurrent.CompletableFuture<java.lang.Boolean> disconnectClient​(@NotNull java.lang.String clientId)
      Forcefully disconnect a client with the specified clientId.
      @NotNull java.util.concurrent.CompletableFuture<java.lang.Boolean> disconnectClient​(@NotNull java.lang.String clientId, boolean preventWillMessage)
      Forcefully disconnect a client with the specified clientId.
      @NotNull java.util.concurrent.CompletableFuture<java.util.Optional<SessionInformation>> getSession​(@NotNull java.lang.String clientId)
      Returns additional client information about a given client with a given client identifier.
      @NotNull java.util.concurrent.CompletableFuture<java.lang.Boolean> invalidateSession​(@NotNull java.lang.String clientId)
      Invalidates the client session for a client with the given client identifier.
      @NotNull java.util.concurrent.CompletableFuture<java.lang.Boolean> isClientConnected​(@NotNull java.lang.String clientId)
      Check if a client with a given identifier is currently connected
    • Method Detail

      • isClientConnected

        @NotNull java.util.concurrent.CompletableFuture<java.lang.Boolean> isClientConnected​(@NotNull java.lang.String clientId)
        Check if a client with a given identifier is currently connected

        CompletableFuture fails with a RateLimitExceededException if the extension service rate limit was exceeded.

        Parameters:
        clientId - The client identifier of the client.
        Returns:
        A CompletableFuture which contains true, if a certain client is currently connected and false otherwise.
        Since:
        4.0.0
      • getSession

        @NotNull java.util.concurrent.CompletableFuture<java.util.Optional<SessionInformation>> getSession​(@NotNull java.lang.String clientId)
        Returns additional client information about a given client with a given client identifier.

        CompletableFuture fails with a RateLimitExceededException if the extension service rate limit was exceeded.

        Parameters:
        clientId - The client identifier of the client.
        Returns:
        A CompletableFuture which contains the SessionInformation for the client, if the session exist.
        Since:
        4.0.0
      • disconnectClient

        @NotNull java.util.concurrent.CompletableFuture<java.lang.Boolean> disconnectClient​(@NotNull java.lang.String clientId)
        Forcefully disconnect a client with the specified clientId.

        If the client specified a Will message, it will be sent. To prevent the sending of Will messages, use the disconnectClient(String, boolean) method.

        CompletableFuture fails with a RateLimitExceededException if the extension service rate limit was exceeded.

        Parameters:
        clientId - The client identifier of the client to disconnect.
        Returns:
        A CompletableFuture which contains a Boolean that is true when the client has been disconnected and false if no client with that id was found.
        Since:
        4.0.0
      • disconnectClient

        @NotNull java.util.concurrent.CompletableFuture<java.lang.Boolean> disconnectClient​(@NotNull java.lang.String clientId,
                                                                                            boolean preventWillMessage)
        Forcefully disconnect a client with the specified clientId.

        Setting the boolean parameter to true will prevent the sending of potential Will messages the client may have specified in its CONNECT packet.

        CompletableFuture fails with a RateLimitExceededException if the extension service rate limit was exceeded.

        Parameters:
        clientId - The client identifier of the client to disconnect.
        preventWillMessage - If true the Will message for this client is not published when the client gets disconnected.
        Returns:
        A CompletableFuture which contains a Boolean that is true when the client has been disconnected and false if no client with that id was found.
        Since:
        4.0.0
      • invalidateSession

        @NotNull java.util.concurrent.CompletableFuture<java.lang.Boolean> invalidateSession​(@NotNull java.lang.String clientId)
        Invalidates the client session for a client with the given client identifier. If the client is currently connected, it will be disconnected as well.

        CompletableFuture fails with a RateLimitExceededException if the extension service rate limit was exceeded.

        CompletableFuture fails with a NoSuchClientIdException if no session for the given clientId exists.

        Parameters:
        clientId - The client identifier of the client which session should be invalidated.
        Returns:
        A CompletableFuture succeeding with a Boolean that is true when the client has been actively disconnected by the broker otherwise false.
        Since:
        4.0.0