Skip to content

Commit

Permalink
#50
Browse files Browse the repository at this point in the history
Fix documentation and samples
  • Loading branch information
njouanin committed Jul 31, 2016
1 parent e3dffa2 commit 18267d1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
12 changes: 12 additions & 0 deletions docs/references/mqttclient.rst
Expand Up @@ -14,6 +14,12 @@ The example below shows how to write a simple MQTT client which subscribes a top

.. code-block:: python
import logging
import asyncio
from hbmqtt.client import MQTTClient, ClientException
from hbmqtt.mqtt.constants import QOS_1, QOS_2
@asyncio.coroutine
def uptime_coro():
C = MQTTClient()
Expand Down Expand Up @@ -53,6 +59,12 @@ This example also shows to method for publishing message asynchronously.

.. code-block:: python
import logging
import asyncio
from hbmqtt.client import MQTTClient
from hbmqtt.mqtt.constants import QOS_1, QOS_2
@asyncio.coroutine
def test_coro():
C = MQTTClient()
Expand Down
5 changes: 3 additions & 2 deletions samples/client_publish_ssl.py
Expand Up @@ -2,6 +2,7 @@
import asyncio

from hbmqtt.client import MQTTClient
from hbmqtt.mqtt.constants import QOS_1, QOS_2



Expand All @@ -28,8 +29,8 @@ def test_coro():
yield from C.connect('mqtts://test.mosquitto.org/', cafile='mosquitto.org.crt')
tasks = [
asyncio.ensure_future(C.publish('a/b', b'TEST MESSAGE WITH QOS_0')),
asyncio.ensure_future(C.publish('a/b', b'TEST MESSAGE WITH QOS_1', qos=0x01)),
asyncio.ensure_future(C.publish('a/b', b'TEST MESSAGE WITH QOS_2', qos=0x02)),
asyncio.ensure_future(C.publish('a/b', b'TEST MESSAGE WITH QOS_1', qos=QOS_1)),
asyncio.ensure_future(C.publish('a/b', b'TEST MESSAGE WITH QOS_2', qos=QOS_2)),
]
yield from asyncio.wait(tasks)
logger.info("messages published")
Expand Down
6 changes: 3 additions & 3 deletions samples/client_publish_ws.py
Expand Up @@ -2,7 +2,7 @@
import asyncio

from hbmqtt.client import MQTTClient

from hbmqtt.mqtt.constants import QOS_1, QOS_2


#
Expand All @@ -29,8 +29,8 @@ def test_coro():
yield from C.connect('wss://test.mosquitto.org:8081/', cafile='mosquitto.org.crt')
tasks = [
asyncio.ensure_future(C.publish('a/b', b'TEST MESSAGE WITH QOS_0')),
asyncio.ensure_future(C.publish('a/b', b'TEST MESSAGE WITH QOS_1', qos=0x01)),
asyncio.ensure_future(C.publish('a/b', b'TEST MESSAGE WITH QOS_2', qos=0x02)),
asyncio.ensure_future(C.publish('a/b', b'TEST MESSAGE WITH QOS_1', qos=QOS_1)),
asyncio.ensure_future(C.publish('a/b', b'TEST MESSAGE WITH QOS_2', qos=QOS_2)),
]
yield from asyncio.wait(tasks)
logger.info("messages published")
Expand Down

0 comments on commit 18267d1

Please sign in to comment.