pyqttier 0.2.2__tar.gz → 0.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqttier
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Convenient wrapper around Paho MQTT
5
5
  Author-email: Jacob Brunson <github@jacobbrunson.com>
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pyqttier"
3
- version = "0.2.2"
3
+ version = "0.2.4"
4
4
  description = "Convenient wrapper around Paho MQTT"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -110,14 +110,16 @@ class Mqtt5Connection(IBrokerConnection):
110
110
  def _on_message(self, client, userdata, msg):
111
111
  self._logger.debug("Got a message to %s : %s", msg.topic, msg.payload.decode())
112
112
  message = Message.from_paho_message(msg)
113
- if message.subscription_id is not None:
114
- sub_id = message.subscription_id
115
- with self._message_handling_lock:
116
- if sub_id in self._subscription_callbacks:
117
- self._subscription_callbacks[sub_id](message)
118
- return
119
- else:
120
- self._logger.debug("No specific callback for subscription ID %d", sub_id)
113
+ if len(message.subscription_ids) > 0:
114
+ for sub_id in message.subscription_ids:
115
+ with self._message_handling_lock:
116
+ if sub_id in self._subscription_callbacks:
117
+ self._subscription_callbacks[sub_id](message)
118
+ return
119
+ else:
120
+ self._logger.debug("No specific callback for subscription ID %d", sub_id)
121
+ else:
122
+ self._logger.debug("No matching subscription ID callbacks found for message.")
121
123
  else:
122
124
  self._logger.warning("No subscription ID found in message properties. This is not usual because we always provide one when subscribing.")
123
125
  with self._message_handling_lock:
@@ -1,5 +1,5 @@
1
1
  from dataclasses import dataclass, field
2
- from typing import Optional, Dict, Any
2
+ from typing import Optional, Dict, Any, List
3
3
  from paho.mqtt.client import MQTTMessage
4
4
  from paho.mqtt.properties import Properties as MqttProperties
5
5
  from paho.mqtt.packettypes import PacketTypes
@@ -13,7 +13,7 @@ class Message:
13
13
  content_type: Optional[str] = None
14
14
  correlation_data: Optional[bytes] = None
15
15
  response_topic: Optional[str] = None
16
- subscription_id: Optional[int] = None # Ignored on publish
16
+ subscription_ids: List[int] = field(default_factory=list) # Ignored on publish
17
17
  message_expiry_interval: Optional[int] = None
18
18
  user_properties: Optional[Dict[str, str]] = field(default_factory=dict)
19
19
 
@@ -64,5 +64,6 @@ class Message:
64
64
  if "MessageExpiryInterval" in properties:
65
65
  msg_obj.message_expiry_interval = properties["MessageExpiryInterval"]
66
66
  if "SubscriptionIdentifier" in properties:
67
- msg_obj.subscription_id = properties["SubscriptionIdentifier"]
67
+ sub_ids = properties["SubscriptionIdentifier"] if isinstance(properties["SubscriptionIdentifier"], list) else [properties["SubscriptionIdentifier"]]
68
+ msg_obj.subscription_ids = sub_ids
68
69
  return msg_obj
@@ -74,7 +74,7 @@ class MockConnection(IBrokerConnection):
74
74
  if self.is_topic_sub(message.topic, topic_filter):
75
75
  if callback is not None:
76
76
  receiving_msg = copy(message)
77
- receiving_msg.subscription_id = sub_id
77
+ receiving_msg.subscription_ids = [sub_id]
78
78
  callback(receiving_msg)
79
79
  return
80
80
 
@@ -95,7 +95,7 @@ class MockConnection(IBrokerConnection):
95
95
  future.set_result(None)
96
96
  return future
97
97
 
98
- def subscribe(self, topic: str, callback: Optional[MessageCallback] = None) -> int:
98
+ def subscribe(self, topic: str, callback: Optional[MessageCallback] = None, qos: int = 1) -> int:
99
99
  """
100
100
  Registers a subscription and returns a subscription ID.
101
101
  """
@@ -716,7 +716,7 @@ wheels = [
716
716
 
717
717
  [[package]]
718
718
  name = "pyqttier"
719
- version = "0.3.0"
719
+ version = "0.2.4"
720
720
  source = { editable = "." }
721
721
  dependencies = [
722
722
  { name = "paho-mqtt" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes