1 2 /** 3 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 * SPDX-License-Identifier: Apache-2.0. 5 */ 6 package software.amazon.awssdk.crt.mqtt; 7 8 /** 9 * Interface used to receive connection events from the CRT 10 */ 11 public interface MqttClientConnectionEvents { 12 /** 13 * Called when the connection was lost (or disconnected), reconnect will be attempted automatically until 14 * disconnect() is called 15 * @param errorCode AWS CRT error code, pass to {@link software.amazon.awssdk.crt.CRT#awsErrorString(int)} for a human readable error 16 */ onConnectionInterrupted(int errorCode)17 void onConnectionInterrupted(int errorCode); 18 19 /** 20 * Called whenever a reconnect succeeds; not called on an initial connect success 21 * @param sessionPresent true if the session has been resumed, false if the session is clean 22 */ onConnectionResumed(boolean sessionPresent)23 void onConnectionResumed(boolean sessionPresent); 24 25 /** 26 * Called on every successful connect and every successful reconnect. 27 * Optional and is not required to be defined. 28 * @param data The data sent from the client alongside the successful connection callback. 29 */ onConnectionSuccess(OnConnectionSuccessReturn data)30 default void onConnectionSuccess(OnConnectionSuccessReturn data) {}; 31 32 /** 33 * Called on every unsuccessful connect and every unsuccessful disconnect. 34 * Optional and is not required to be defined. 35 * @param data The data sent from the client alongside the failed connection callback. 36 */ onConnectionFailure(OnConnectionFailureReturn data)37 default void onConnectionFailure(OnConnectionFailureReturn data) {}; 38 39 /** 40 * Called when the connection was disconnected and shutdown successfully. 41 * Optional and is not required to be defined. 42 * @param data The data sent from the client alongside the successful disconnect. 43 */ onConnectionClosed(OnConnectionClosedReturn data)44 default void onConnectionClosed(OnConnectionClosedReturn data) {}; 45 } 46