pyqttier 0.2.1__tar.gz → 0.2.2__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.1
3
+ Version: 0.2.2
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.1"
3
+ version = "0.2.2"
4
4
  description = "Convenient wrapper around Paho MQTT"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -23,6 +23,7 @@ class Mqtt5Connection(IBrokerConnection):
23
23
  class PendingSubscription:
24
24
  topic: str
25
25
  subscription_id: int
26
+ qos: int
26
27
 
27
28
  @dataclass
28
29
  class PendingPublish:
@@ -141,7 +142,7 @@ class Mqtt5Connection(IBrokerConnection):
141
142
  sub_props = MqttProperties(PacketTypes.SUBSCRIBE)
142
143
  sub_props.SubscriptionIdentifier = pending_subscr.subscription_id
143
144
  self._client.subscribe(
144
- pending_subscr.topic, qos=1, properties=sub_props
145
+ pending_subscr.topic, qos=pending_subscr.qos, properties=sub_props
145
146
  )
146
147
  while not self._queued_messages.empty():
147
148
  try:
@@ -183,7 +184,7 @@ class Mqtt5Connection(IBrokerConnection):
183
184
  self._queued_messages.put(pending_pub)
184
185
  return fut
185
186
 
186
- def subscribe(self, topic: str, callback: Optional[MessageCallback] = None) -> int:
187
+ def subscribe(self, topic: str, callback: Optional[MessageCallback] = None, qos: int = 1) -> int:
187
188
  """Subscribes to a topic. If the connection is not established, the subscription is queued.
188
189
  Returns the subscription ID.
189
190
  """
@@ -192,10 +193,10 @@ class Mqtt5Connection(IBrokerConnection):
192
193
  self._logger.debug("Subscribing to %s", topic)
193
194
  sub_props = MqttProperties(PacketTypes.SUBSCRIBE)
194
195
  sub_props.SubscriptionIdentifier = sub_id
195
- self._client.subscribe(topic, qos=1, properties=sub_props)
196
+ self._client.subscribe(topic, qos=qos, properties=sub_props)
196
197
  else:
197
198
  self._logger.debug("Pending subscription to %s", topic)
198
- self._queued_subscriptions.put(self.PendingSubscription(topic, sub_id))
199
+ self._queued_subscriptions.put(self.PendingSubscription(topic, sub_id, qos))
199
200
  if callback is not None:
200
201
  self._subscription_callbacks[sub_id] = callback
201
202
  else:
@@ -17,7 +17,7 @@ class IBrokerConnection(ABC):
17
17
  pass
18
18
 
19
19
  @abstractmethod
20
- def subscribe(self, topic: str, callback: Optional[MessageCallback] = None) -> int:
20
+ def subscribe(self, topic: str, callback: Optional[MessageCallback] = None, qos: int = 1) -> int:
21
21
  """
22
22
  Subscribes to the provided topic. May queue the subscription until the connection to the broker is established.
23
23
  When a message is received on the topic, the provided callback will be executed if provided.
@@ -63,4 +63,6 @@ class Message:
63
63
  msg_obj.response_topic = properties["ResponseTopic"]
64
64
  if "MessageExpiryInterval" in properties:
65
65
  msg_obj.message_expiry_interval = properties["MessageExpiryInterval"]
66
+ if "SubscriptionIdentifier" in properties:
67
+ msg_obj.subscription_id = properties["SubscriptionIdentifier"]
66
68
  return msg_obj
@@ -716,7 +716,7 @@ wheels = [
716
716
 
717
717
  [[package]]
718
718
  name = "pyqttier"
719
- version = "0.2.0"
719
+ version = "0.3.0"
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
File without changes