Interface ClientLifecycleEventListener
-
public interface ClientLifecycleEventListener
AClientLifecycleEventListener
contains methods that allow custom logic to be executed when:- A client starts an MQTT connection
- The authentication for a client is successful
- A client is disconnected
The methods here are for informational purpose only and do not allow modification of the MQTT packets exchanged between the client and the server. Interceptors and Packet Modifiers can be used to modify MQTT packets.
- Since:
- 4.0.0, CE 2019.1
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
onAuthenticationFailedDisconnect(@NotNull AuthenticationFailedInput authenticationFailedInput)
This method is called when a client is disconnected by the server when the authentication for this MQTT connection failed.void
onAuthenticationSuccessful(@NotNull AuthenticationSuccessfulInput authenticationSuccessfulInput)
This method is called by HiveMQ after an MQTT connection is successfully authenticated.default void
onClientInitiatedDisconnect(@NotNull ClientInitiatedDisconnectInput clientInitiatedDisconnectInput)
This method is called when a client disconnects by sending a MQTT DISCONNECT packet to the server.default void
onConnectionLost(@NotNull ConnectionLostInput connectionLostInput)
This method is called when a client is disconnected because the connection is lost.void
onDisconnect(@NotNull DisconnectEventInput disconnectEventInput)
This method is the default method called by HiveMQ for all cases where a client disconnects.void
onMqttConnectionStart(@NotNull ConnectionStartInput connectionStartInput)
This method is called by HiveMQ when an MQTT connection is started by the client.default void
onServerInitiatedDisconnect(@NotNull ServerInitiatedDisconnectInput serverInitiatedDisconnectInput)
This method is called when a client is disconnected by the server with an MQTT DISCONNECT or CONNACK packet for any other reason than a failed authentication.
-
-
-
Method Detail
-
onMqttConnectionStart
void onMqttConnectionStart(@NotNull ConnectionStartInput connectionStartInput)
This method is called by HiveMQ when an MQTT connection is started by the client. The MQTT connection starts when the client sends an MQTT CONNECT packet to the server.This method is executed after the ConnectInboundPacketModifier and the information represented in the input can already modified by an extension.
- Parameters:
connectionStartInput
- TheConnectionStartInput
containing information about the MQTT CONNECT packet, the client and the connection.- Since:
- 4.0.0, CE 2019.1
-
onAuthenticationSuccessful
void onAuthenticationSuccessful(@NotNull AuthenticationSuccessfulInput authenticationSuccessfulInput)
This method is called by HiveMQ after an MQTT connection is successfully authenticated.- Parameters:
authenticationSuccessfulInput
- TheAuthenticationSuccessfulInput
containing information about the client and the connection.- Since:
- 4.0.0, CE 2019.1
-
onDisconnect
void onDisconnect(@NotNull DisconnectEventInput disconnectEventInput)
This method is the default method called by HiveMQ for all cases where a client disconnects.To implement custom logic for specific disconnect cases the following methods can be overridden:
onAuthenticationFailedDisconnect(AuthenticationFailedInput)
onClientInitiatedDisconnect(ClientInitiatedDisconnectInput)
onConnectionLost(ConnectionLostInput)
onServerInitiatedDisconnect(ServerInitiatedDisconnectInput)
If all the above methods are implemented, onDisconnect will never be called.
- Parameters:
disconnectEventInput
- TheDisconnectEventInput
containing information about the exact disconnect reason, the client and the connection.- Since:
- 4.0.0, CE 2019.1
-
onAuthenticationFailedDisconnect
default void onAuthenticationFailedDisconnect(@NotNull AuthenticationFailedInput authenticationFailedInput)
This method is called when a client is disconnected by the server when the authentication for this MQTT connection failed.By default this calls
onDisconnect(com.hivemq.extension.sdk.api.events.client.parameters.DisconnectEventInput)
. This method can be overridden to execute custom logic for the specific disconnect when the authentication fails.- Parameters:
authenticationFailedInput
- TheAuthenticationFailedInput
containing information about the exact disconnect reason, the client and the connection.- Since:
- 4.0.0, CE 2019.1
-
onConnectionLost
default void onConnectionLost(@NotNull ConnectionLostInput connectionLostInput)
This method is called when a client is disconnected because the connection is lost.By default this calls
onDisconnect(com.hivemq.extension.sdk.api.events.client.parameters.DisconnectEventInput)
. This method can be overridden to execute custom logic for the specific disconnect when the connection is lost.In this case a reason code, reason string and user properties are not present in the input.
- Parameters:
connectionLostInput
- TheConnectionLostInput
containing information about the client and the connection.- Since:
- 4.0.0, CE 2019.1
-
onClientInitiatedDisconnect
default void onClientInitiatedDisconnect(@NotNull ClientInitiatedDisconnectInput clientInitiatedDisconnectInput)
This method is called when a client disconnects by sending a MQTT DISCONNECT packet to the server.By default this calls
onDisconnect(com.hivemq.extension.sdk.api.events.client.parameters.DisconnectEventInput)
. This method can be overridden to execute a custom logic when the client initiates the disconnect.- Parameters:
clientInitiatedDisconnectInput
- TheClientInitiatedDisconnectInput
containing information about the exact disconnect reason, the client and the connection.- Since:
- 4.0.0, CE 2019.1
-
onServerInitiatedDisconnect
default void onServerInitiatedDisconnect(@NotNull ServerInitiatedDisconnectInput serverInitiatedDisconnectInput)
This method is called when a client is disconnected by the server with an MQTT DISCONNECT or CONNACK packet for any other reason than a failed authentication.By default this calls
onDisconnect(com.hivemq.extension.sdk.api.events.client.parameters.DisconnectEventInput)
. This method can be overridden to execute custom logic when a client is disconnected by the server.- Parameters:
serverInitiatedDisconnectInput
- TheServerInitiatedDisconnectInput
containing information about the exact disconnect reason, the client and the connection.- Since:
- 4.0.0, CE 2019.1
-
-