@@ -78,7 +78,7 @@ def on_lifecycle_attempting_connect(lifecycle_attempting_connect_data: mqtt5.Lif
78
78
# Callback for the lifecycle event Connection Success
79
79
def on_lifecycle_connection_success (lifecycle_connect_success_data : mqtt5 .LifecycleConnectSuccessData ):
80
80
connack_packet = lifecycle_connect_success_data .connack_packet
81
- print ("Lifecycle Connection Success with reason_code :{}\n " .format (
81
+ print ("Lifecycle Connection Success with reason code :{}\n " .format (
82
82
repr (connack_packet .reason_code )))
83
83
connection_success_event .set ()
84
84
@@ -89,6 +89,12 @@ def on_lifecycle_connection_failure(lifecycle_connection_failure: mqtt5.Lifecycl
89
89
lifecycle_connection_failure .exception ))
90
90
91
91
92
+ # Callback for the lifecycle event Disconnection
93
+ def on_lifecycle_disconnection (lifecycle_disconnect_data : mqtt5 .LifecycleDisconnectData ):
94
+ print ("Lifecycle Disconnected with reason code:{}" .format (
95
+ lifecycle_disconnect_data .disconnect_packet .reason_code if lifecycle_disconnect_data .disconnect_packet else "None" ))
96
+
97
+
92
98
if __name__ == '__main__' :
93
99
print ("\n Starting MQTT5 X509 PubSub Sample\n " )
94
100
message_count = args .input_count
@@ -107,6 +113,7 @@ def on_lifecycle_connection_failure(lifecycle_connection_failure: mqtt5.Lifecycl
107
113
on_lifecycle_attempting_connect = on_lifecycle_attempting_connect ,
108
114
on_lifecycle_connection_success = on_lifecycle_connection_success ,
109
115
on_lifecycle_connection_failure = on_lifecycle_connection_failure ,
116
+ on_lifecycle_disconnection = on_lifecycle_disconnection ,
110
117
client_id = args .input_clientId )
111
118
112
119
0 commit comments