diff --git a/quickstart/hono_commands.py b/quickstart/hono_commands.py index db6e78c7..5011c230 100644 --- a/quickstart/hono_commands.py +++ b/quickstart/hono_commands.py @@ -56,6 +56,11 @@ def on_message(self, event): print('[ok]', command) else: print('[error]') + event.receiver.close() + event.connection.close() + + def on_connection_closed(self, event): + print('[connection closed]') os.kill(os.getpid(), signal.SIGINT) diff --git a/quickstart/hono_commands_fu.py b/quickstart/hono_commands_fu.py index b7d2c6e3..d10ce8e1 100644 --- a/quickstart/hono_commands_fu.py +++ b/quickstart/hono_commands_fu.py @@ -57,7 +57,12 @@ def on_message(self, event): print('[ok]', "fu") else: print('[error]') - os.kill(os.getpid(), signal.SIGINT) + event.receiver.close() + event.connection.close() + + def on_connection_closed(self, event): + print('[connection closed]') + os.kill(os.getpid(), signal.SIGINT) class CommandsInvoker(MessagingHandler): @@ -88,7 +93,7 @@ def on_sendable(self, event): value=value) print(payload) msg = Message(body=payload, address='{}/{}'.format(self.address, device_id), content_type="application/json", - subject="fu", reply_to=reply_to_address, correlation_id=correlation_id, id=str(uuid.uuid4())) + subject=self.action, reply_to=reply_to_address, correlation_id=correlation_id, id=str(uuid.uuid4())) event.sender.send(msg) event.sender.close() event.connection.close() @@ -121,10 +126,16 @@ def on_message(self, event): print(json.dumps(body, indent=2)) if body["value"]["state"] == "SUCCESS": print('[successful upload]') - os.kill(os.getpid(), signal.SIGINT) + event.receiver.close() + event.connection.close() elif body["value"]["state"] == "FAILED": print('[failed upload]') - os.kill(os.getpid(), signal.SIGINT) + event.receiver.close() + event.connection.close() + + def on_connection_closed(self, event): + print('[connection closed]') + os.kill(os.getpid(), signal.SIGINT) # Parse command line args diff --git a/quickstart/hono_commands_su.py b/quickstart/hono_commands_su.py index 2d1e480f..780fc415 100644 --- a/quickstart/hono_commands_su.py +++ b/quickstart/hono_commands_su.py @@ -76,6 +76,11 @@ def on_message(self, event): print('[ok]', "su") else: print('[error]') + event.receiver.close() + event.connection.close() + + def on_connection_closed(self, event): + print('[connection closed]') os.kill(os.getpid(), signal.SIGINT)