• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 package software.amazon.awssdk.crt.mqtt5;
6 
7 import software.amazon.awssdk.crt.mqtt5.packets.DisconnectPacket;
8 
9 /**
10  * The data returned when OnDisconnect is invoked in the LifecycleEvents callback.
11  * The data contained within can be gotten using the <code>get</code> functions.
12  * For example, <code>getDisconnectPacket</code> will return the DisconnectPacket from the server.
13  */
14 public class OnDisconnectionReturn {
15     private int errorCode;
16     private DisconnectPacket disconnectPacket;
17 
18     /**
19      * Returns the error code returned from the server on the disconnection.
20      * Pass to {@link software.amazon.awssdk.crt.CRT#awsErrorString(int)} for a human readable error.
21      * @return The error code returned from the server.
22      */
getErrorCode()23     public int getErrorCode() {
24         return errorCode;
25     }
26 
27     /**
28      * Returns the ConnAckPacket returned from the server on the disconnection, or Null if none was returned.
29      * @return The ConnAckPacket returned from the server.
30      */
getDisconnectPacket()31     public DisconnectPacket getDisconnectPacket() {
32         return disconnectPacket;
33     }
34 
35     /**
36      * This is only called in JNI to make a new OnDisconnectionReturn.
37      */
OnDisconnectionReturn(int newErrorCode, DisconnectPacket newDisconnectPacket)38     private OnDisconnectionReturn(int newErrorCode, DisconnectPacket newDisconnectPacket)
39     {
40         this.errorCode = newErrorCode;
41         this.disconnectPacket = newDisconnectPacket;
42     }
43 }
44