You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
topics_to_handlers: callback function which gets the topic to handler map from the channel manager
110
+
find_wildcard_handler: callback function which gets the wildcard topic handler from the channel manager
109
111
is_root: Whether or not the client can configure exchanges and queues themselves (core services), or if this must be delegated to a Core Service (SDK Clients/Services)
"""Unsubscribe from a topic over the pre-existing connection.
174
186
175
187
Args:
176
188
topic: Topic to unsubscribe from.
177
189
"""
178
-
self._connection.unsubscribe(topic)
190
+
resolved_topic=_hierarchy_2_mqtt(topic)
191
+
self._connection.unsubscribe(resolved_topic)
179
192
180
193
def_on_message(
181
194
self,
@@ -190,7 +203,11 @@ def _on_message(
190
203
userdata: MQTT user data
191
204
message: MQTT message
192
205
"""
206
+
# NOTE: should not need to convert the MQTT topic to the protocol agnostic representation, as we only change the wildcard format (which won't show up as the message topic)
- `/` (topic separator; note that this is '.' on the broker)
19
+
- `*` (wildcard for exactly one word)
20
+
- `#` (wildcard for any number of words, but can ONLY appear at the end of the topic string, see section 4.7.1.2 at https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718107)
"""Start listening for messages on a channel on all configured brokers.
69
87
70
-
Use the format ${TOPIC}/${TOPIC}/${TOPIC} ... for the channel name, protocol implementations
71
-
are responsible for converting the string to a valid channel.
88
+
The provided channel value should be PROTOCOL AGNOSTIC. Use the following symbols when constructing a topic:
89
+
- `/` - topic separator
90
+
- `*` - exactly one word
91
+
- `#` - any number of words (however, this can only be used as the LAST character)
92
+
93
+
Protocol implementations are responsible for converting the string to a valid channel.
72
94
73
95
This function should usually only be called before you've connected,
74
96
but it's okay to call it after connecting. (Mostly used for Clients.)
75
97
76
98
Params:
77
-
channel: string of the channel which we should start listening to
99
+
channel: string of the channel which we should start listening to, remember to follow the above protocol agnostic convention
78
100
callbacks: functions to call on subscribing to a message
79
101
persist: if True, expect the associated message queue to live long; if False, it will only live the duration of the application.
80
102
Any queue associated with a Service should always set this to True. Clients will need to subscribe to their own, temporary queues, and should set this to False.
81
103
queue_name: the name of the queue to subscribe to. This is generally hardcoded for Core Services, but autogenerated for SDK Services and Clients.
Note that this function gets accessed as a callback from the direct broker implementations.
148
+
These channels cannot be wildcards, and incoming topics must match the channel topics exactly. Note that this function gets accessed as a callback from the direct broker implementations.
"""Get the wildcard topic handler for a given topic, if it exists.
157
+
158
+
This is an inefficient lookup, so should only be used if we fail to find a non-wildcard match for an incoming topic. Note that this function gets accessed as a callback from the direct broker implementations.
159
+
160
+
Returns:
161
+
the topic handler associated with the topic, if it exists; None otherwise
0 commit comments