Skip to content

Commit

Permalink
Merge pull request #810 from meejah/mqtt-example-fixup
Browse files Browse the repository at this point in the history
fix mqtt example
  • Loading branch information
oberstet committed Apr 6, 2017
2 parents 459da03 + 937f7de commit 8c10844
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions examples/twisted/wamp/mqtt/wamp-client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from os import environ
from base64 import b64encode

from autobahn.twisted.wamp import ApplicationSession
from autobahn.twisted.wamp import ApplicationRunner
Expand All @@ -21,18 +22,12 @@ def onJoin(self, details):
# are encoded into a JSON body as "the" MQTT message. Here we
# also ask WAMP to send our message back to us.
yield self.publish(
u"mqtt.test_topic", "some data via WAMP",
u"mqtt.test_topic", b64encode("some data via WAMP"),
mqtt_message=True,
mqtt_qos=1,
options=PublishOptions(exclude_me=False),
)

# if you send *just* mqtt_qos and mqtt_message kwargs, and no
# args then it will take mqtt_message as "the" payload
yield self.publish(
u"mqtt.test_topic",
mqtt_qos=0,
mqtt_message="hello from WAMP",
)

def on_event(self, *args, **kw):
print("'{}' event: args={}, kwargs={}".format(self.topic, args, kw))

Expand Down

0 comments on commit 8c10844

Please sign in to comment.