From ad04b35b61d20df7f62f460b8d784251d9fbcb3c Mon Sep 17 00:00:00 2001
From: Matthias Bodenbenner <m.bodenbenner@wzl-mq.rwth-aachen.de>
Date: Thu, 11 Jan 2024 07:41:05 +0100
Subject: [PATCH] 2.6.1 - bug fix

---
 PyPI-README.md     | 10 ++++++++--
 README.md          |  5 ++++-
 setup.py           |  2 +-
 src/mqtt/client.py |  3 ++-
 4 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/PyPI-README.md b/PyPI-README.md
index d84d4c2..8c1c059 100644
--- a/PyPI-README.md
+++ b/PyPI-README.md
@@ -1,7 +1,6 @@
 # WZL-MQTT
 
-Current stable version: 2.5.4
-
+Current stable version: 2.6.1
 ## Documentation
 
 For the full API documentation, view [https://iot.wzl-mq.rwth-aachen.de/documentation/libs/mqtt/](https://iot.wzl-mq.rwth-aachen.de/documentation/libs/mqtt/).
@@ -79,6 +78,13 @@ while True:
 
 ## Changelog
 
+**2.6.1** - 2024-01-11
+  - decoupled name of the client used locally from the name used when connecting to the broker to ensure independent clients using this library can use the same names locally   
+
+**2.6.0** - 2024-01-10
+  - added the classmethod "client_names()" to client to retrieve the name of all instances
+  - the classmethod "get(username)" of the client raises the "ChildNotFoundError" if there is no instance having the specified username
+
 **2.5.4** - 2023-04-18
   - fixed usage of a randomized client_id, so that the same credentials can be used for multiple clients in parallel
 
diff --git a/README.md b/README.md
index fa7446f..86a68f7 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 # WZL-MQTT
 
-Current stable version: 2.6.0
+Current stable version: 2.6.1
 
 ## Documentation
 
@@ -90,6 +90,9 @@ the European Union’s Horizon 2020 research and innovation programme and the EM
 
 ## Changelog
 
+**2.6.1** - 2024-01-11
+  - decoupled name of the client used locally from the name used when connecting to the broker to ensure independent clients using this library can use the same names locally   
+
 **2.6.0** - 2024-01-10
   - added the classmethod "client_names()" to client to retrieve the name of all instances
   - the classmethod "get(username)" of the client raises the "ChildNotFoundError" if there is no instance having the specified username
diff --git a/setup.py b/setup.py
index 5e3a0a2..0ca7c18 100644
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,7 @@ with open("PyPI-README.md", "r", encoding="utf-8") as fh:
     long_description = fh.read()
 
 setup(name='wzl-mqtt',
-      version='2.6.0',
+      version='2.6.1',
       url='https://git-ce.rwth-aachen.de/wzl-mq-public/iot/mqtt/',
       project_urls={
             "Bug Tracker": "https://git-ce.rwth-aachen.de/wzl-mq-public/iot/mqtt/-/issues",
diff --git a/src/mqtt/client.py b/src/mqtt/client.py
index 03434b6..790cecf 100644
--- a/src/mqtt/client.py
+++ b/src/mqtt/client.py
@@ -44,6 +44,7 @@ class MQTTClient:
             'MQTTClient') if logger is not None else Logger().get('MQTTClient')
 
         self.name = username if username is not None else str(uuid.uuid4())
+        parentname = f'{username}-{str(uuid.uuid4())}' if username is not None else str(uuid.uuid4())
 
         if self.name in MQTTClient.instances:
             self._logger.error(
@@ -52,7 +53,7 @@ class MQTTClient:
 
         MQTTClient.instances[self.name] = self
         self.prefix = prefix
-        self._client = mqtt.Client(self.name, *args, **kwargs)
+        self._client = mqtt.Client(parentname, *args, **kwargs)
         self._client.on_connect = self._on_connect
         self._client.on_disconnect = self._on_disconnect
 
-- 
GitLab