-
Notifications
You must be signed in to change notification settings - Fork 84
Open
Description
The example denotes the following.
async with Client("test.mosquitto.org") as client:
async with client.messages() as messages:
await client.subscribe("humidity/#")
async for message in messages:
print(message.payload)
If a user wants to also test for temperature:
async with Client("test.mosquitto.org") as client:
async with client.messages() as messages:
await client.subscribe("humidity/#")
await client.subscribe("temperature/#")
async for message in messages:
if message.topic.startswith('humidity'):
print(message.payload)
elif message.topic.startswith('temperature'):
print(message.payload)
Is there any way to do this more elegantly? Maybe even in a concurrent way?
Pseudo:
async with Client("test.mosquitto.org") as client:
async with client.messages() as messages:
await client.subscribe("humidity/#")
async for message in messages:
print(message.payload)
async with client.messages() as messages:
await client.subscribe("temperature/#")
async for message in messages:
print(message.payload)
empicano, Art-S-D and hugokernel
Metadata
Metadata
Assignees
Labels
No labels